I'm trying to create an instance of a Java nested class but when compile I see is not a legal prefix for a constructor.
I have a Java library with classes A1 and A2 defined like this
public class A1 {
public class A2 {
public A2() {...}
}
public A2 getA2() {
return new A2();
}
}
I'm trying to extend this class in Scala and doing something like this
class B(...) extends A1(...) {
override def getA2() = {
new A1#A2()
}
}
When I compile I get this error
A1 is not a legal prefix for a constructor
[error] new A1#A2()
[error] ^
[error] one error found
[error] (connector/test:compileIncremental) Compilation failed
[error] Total time: 2 s, completed May 21, 2020 11:34:44 PM
[IJ]>
This seems to be a known compiler issue (see github issue), the workaround won't work here as I cannot change the library code.