-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:overloadingarea:varianceIssues related to covariance & contravariance.Issues related to covariance & contravariance.compat:javaitype:bug
Description
Compiler version
3.7.3
Minimized code
Java part:
public class JavaPart {
public interface A { }
public interface B extends A {
int onlyInB();
}
public interface Lvl1 {
A[] getData();
}
public interface Lvl2 extends Lvl1 {
@Override
B[] getData();
}
public interface Lvl3 extends Lvl2, Lvl1 { }
}Scala part:
def test(lvl3: JavaPart.Lvl3): Unit =
lvl3.getData.head.onlyInB()Output
value onlyInB is not a member of JavaPart.A
lvl3.getData.head.onlyInB()
Expectation
It should compile and lvl3.getData should resolve to Lvl2.getData.
The problem seems to be that Lvl1 is listed as last implemented interface in Lvl3 and thus the compiler selects Lvl1.getData.
If Lvl1 is moved before Lvl2 it works as expected. Also (lvl3: JavaPart.Lvl2).getData.head.onlyInB() makes it work as well.
He-Pin, unkarjedy and GedochaoHe-Pin
Metadata
Metadata
Assignees
Labels
area:overloadingarea:varianceIssues related to covariance & contravariance.Issues related to covariance & contravariance.compat:javaitype:bug