Closed
Description
A method in the following Java code returns an inner class of a generic class. In scalac, the type is J_1#A[String]#B[String]
, in dotty it is j.A[T]#B[String]
:
- the type argument of
A
is lost, - the prefix depends on the receiver of the method.
J_1.java:
public class J_1{
public class A<T>{
public class B<U>{}
}
A<String>.B<String> m(){
J_1 j = new J_1();
A<String> a = j.new A<>();
A<String>.B<String> b = a.new B<>();
return b;
}
}
S_2.scala:
object O{
def main(args: Array[String]) = {
val j = new J_1
val ab: J_1#A[String]#B[String] = j.m()
}
}
Output:
-- [E007] Type Mismatch Error: S_2.scala:4:41 --------------
4 | val ab: J_1#A[String]#B[String] = j.m()
| ^^^^^
| Found: j.A[T]#B[String]
| Required: J_1#A[String]#B[String]
There seems to be a simple fix so I intend to post a PR.
Metadata
Metadata
Assignees
Labels
No labels