-
Bug
-
Resolution: Fixed
-
P3
-
None
-
Verified
In a case of two functional interface declarations like the following, most-specific should not claim that one type is better than the other (for an explicit lambda):
interface T2 {
String apply(int arg);
}
interface T1 extends T2 {
default String apply(int arg) { return "x"; }
Object get(int arg);
}
void m(T1 arg);
void m(T2 arg);
m((int x) -> "a"); // ambiguous
T1 is "nominally" better, but T2 is "structurally" better. So neither one is clearly the better choice, which is what most-specific is looking for.
In contrast, for an implicit lambda, no structural comparison is made, and so the subtype (T2) should be preferred.
m(x -> "a"); // resolve to m(T2)
interface T2 {
String apply(int arg);
}
interface T1 extends T2 {
default String apply(int arg) { return "x"; }
Object get(int arg);
}
void m(T1 arg);
void m(T2 arg);
m((int x) -> "a"); // ambiguous
T1 is "nominally" better, but T2 is "structurally" better. So neither one is clearly the better choice, which is what most-specific is looking for.
In contrast, for an implicit lambda, no structural comparison is made, and so the subtype (T2) should be preferred.
m(x -> "a"); // resolve to m(T2)
- relates to
-
JDK-8023759 Lambda Spec: Minimize analysis of boxing in most-specific test
-
- Closed
-