Say I have the following class defined in java:
public class A
{
public class B
{
}
public B[] someFunc() {...}
}
And I am trying to access it in scala as follows:
val array: Array[A#B] = a.someFunc()
The compiler gives me the following warning:
*type mismatch; found : Array[a.B] required: Array[A#B] Note: a.B <: A#B, but class Array is invariant in type T. You may wish to investigate a wildcard type such as `_ <: A#B*
I am not sure of the correct syntax I should use to get over this error. I tried using the following but it will not compile:
val array: Array[T <: A#B] = a.someFunc()
But I have found away to get over the problem by passing it to a function:
def test[T <: A#B](array: Array[T]) = ...
test(a.someFunc())
which compiles fine.
How would I achieve the correct type assignment without having to define this test function?
Thanks
Des