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
Java interface methods always non-concrete in lookup in Java classes #10580
base: 2.13.x
Are you sure you want to change the base?
Conversation
At least my failure is "interesting"...
|
Your idea looks good! Makes sense to me, after looking at the JLS. |
Test passes after narrowing the change down to So
Then |
Thanks, I got side-tracked reading Mixin. If testing I also noticed there is a test for |
Yes! 4️⃣0️⃣ 🎂 |
369e7bd
to
b28f79c
Compare
b28f79c
to
12d6677
Compare
It should work also with abstract methods. I haven't given it more thought/time yet. |
🤔 what should work? |
Your words are ripe with wisdom, my friend! |
👍 I see.. |
4169823
to
d3b6164
Compare
So there are two competing factors: refining the result type and being a SAM type. Turns out that scalac permits too many types as SAM: public interface A {
int sam(int x);
default A m() { return x -> x; }
}
public interface B extends A {
B m();
} Welcome to Scala 2.13.12 (OpenJDK 64-Bit Server VM, Java 17.0.6).
Type in expressions for evaluation. Or try :help.
scala> val b: B = x => x
val b: B = $Lambda$1037/0x00000008005f5428@698ac187
scala> b.m
java.lang.AbstractMethodError: Receiver class $Lambda$1037/0x00000008005f5428 does not define or inherit an implementation of the resolved method 'abstract B m()' of interface B.
at B.m(B.java:1) On the flipside, we need to keep treating the following as SAM: interface B {
int sam(int x);
@Override boolean equals(Object other);
}
I'll keep digging :) |
d3b6164
to
bb218b8
Compare
I forgot that this has lrytz assistance in its history, what we call either rytzassist or rytztory. I'll redraft for 2.13.15 and try to understand it, then ping for a rytzassist. |
When selecting from a Java type, looking up the member takes interface members as non-concrete.
Fixes scala/bug#12892