Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
XYZboom opened this issue Jan 5, 2025 · 4 comments
Labels
area:overloading area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug regression:scala2

Comments

@XYZboom
Copy link

XYZboom commented Jan 5, 2025

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]
@XYZboom XYZboom added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 5, 2025
@He-Pin
Copy link

He-Pin commented Jan 5, 2025

this should be an override nothing too

@sjrd
Copy link
Member

sjrd commented Jan 5, 2025

That error is legit. IO is invariant, so a class cannot be both an IO[Object] and an IO[String].

@XYZboom
Copy link
Author

XYZboom commented Jan 5, 2025

That error is legit. IO is invariant, so a class cannot be both an IO[Object] and an IO[String].

Yes, so the compiler should not passed the above code. That's why I said false-negative.

@sjrd
Copy link
Member

sjrd commented Jan 5, 2025

Oops, you're right. I misread the issue.

@Gedochao Gedochao added area:reporting Error reporting including formatting, implicit suggestions, etc area:overloading regression:scala2 and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:overloading area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug regression:scala2
Projects
None yet
Development

No branches or pull requests

4 participants