Hi.
Please, if you ask a question stating that you get a compiler error, also say what the error is. That makes it much easier to help. Thanks!
Here, the problem is two fold (at least the explanation). First, Array is something special because of the JVM internals. An Int
Array is represented differently from a Double
Array (at the byte level).
But, normally, parameterized types undergo type erasure, so at runtime (at the byte level) they look all the same. So your code becomes:
def func1(data: UserDefined[_]) = {
}
def func1(data: UserDefined[_]) = {
}
which means that these two functions have exactly the same signature, which is not possible.
Either do not use overloading and you are safe. Otherwise, you could also parameterize the function itself:
def func1[T](data: UserDefined[T]) = { ... }