Hi,
I'm having a problem that looks like a bug in the scala compiler (tested with 2.11.5).
Given the following scala code:
trait W
trait T1
trait T2 extends T1
object O1 {
type t = T1 with T2
}
class C1[w<:W](o: O1.t)
class C2 extends T1 with T2
And the given Java code:
public class Main {
public static void main(String[] args) {
new C1<>(new C2());
}
}
Execution results in the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: C1.<init>(LT1;)V
at Main.main(Main.java:4)
(Note that calling the constructor similarly from Scala does not cause this exception)
It seems that the declaration of the C1 <init> method in the bytecode is not correct. it looks like:
// access flags 0x1
// signature (LT1;)V
// declaration: void <init>(T1)
public <init>(LT2;)V
And in the bytecode compiled from the Main java class, the call to the constructor is compiled as:
INVOKESPECIAL C1.<init> (LT1;)V
Here the java code tries to call an <init> method that takes a LT1 parameter while the actual <init> method takes a LT2 param. It looks like there is a discrepancy between the method prototype and the generic signature info.
This looks similar to
https://issues.scala-lang.org/browse/SI-7007 but seems to happen when the constructor is called from Java.
Should I open a Jira ?
Thanks,
Matthieu.