Skip to content

False-negative conflicting base types when inherits Java class and interface. #22311

Open
@XYZboom

Description

@XYZboom

Compiler version

3.6.3-RC2, 3.6.4-RC1-bin-20241231-1f0c576-NIGHTLY

Minimized code

// FILE: I0.java
public interface I0<T> {
    public default T func(T t) {
        return t;
    }
}
// FILE: I1.java
public interface I1 extends I0<String> {
    @Override
    default String func(String s) {
        return s;
    }
}
abstract class A0 extends I1 with I0[Object] {
  override def func(s: Object): String = super.func(s)
}

Output

passed

Expectation

error: class A0 has conflicting base types I0[String] and I0[Object].
We can see a similar but not very clear error in scala2:

illegal inheritance;
 self-type A0 does not conform to I0[Object]'s selftype I0[Object]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions