-
Bug
-
Resolution: Fixed
-
P4
-
8
-
b102
-
Not verified
As pointed out in JDK-8037788, the specification of more-specific function type return types fails to account for the possibility that the a lambda body has no return expressions. javac has the same problem, causing many types are considered "more specific" than many others, even when this is illogical. The effect is surprising ambiguities and surprising explanations for ambiguities.
The following should succeed under both the current spec, and as revised byJDK-8037788, but produces an error:
interface I { Object run(); }
interface J { String run(); }
void m(I arg) {}
void m(J arg) {}
void test() {
m(() -> { throw new RuntimeException(); });
}
The following should succeed under both the current spec, and as revised by
interface I { Object run(); }
interface J { String run(); }
void m(I arg) {}
void m(J arg) {}
void test() {
m(() -> { throw new RuntimeException(); });
}
- relates to
-
JDK-8034223 Most-specific should not have any special treatment for boxed vs. unboxed types
-
- Closed
-
-
JDK-8037788 15.12.2.5: Need to account for lambda bodies with no return expressions
-
- Closed
-