-
Bug
-
Resolution: Fixed
-
P4
-
8
-
b102
-
Verified
Per JDK-8042285, the JLS rules for functional interface comparison during most-specific testing failed to account for generic function types. This can be addressed in the same way as overriding: ensuring the two signatures have equivalent type parameters (same number, equivalent bounds), and then alpha-renaming from one to the other. (See JDK-8042285 comments for details.)
javac does nothing with any type parameters in the signatures, and should be updated.
interface F1 { <X> Object apply(X arg); }
interface F2 { <Y> String apply(Y arg); }
interface F3 { <X> Object apply(Object arg); }
interface F4 { String apply(Object arg); }
static void m1(F1 p) { System.out.println("F1"); }
static void m1(F2 f) { System.out.println("F2"); }
static void m2(F3 p) { System.out.println("F3"); }
static void m2(F4 f) { System.out.println("F4"); }
static String foo(Object in) { return "abc"; }
static void test(boolean cond) {
m1(ThisTestClass::foo); // expected: ok; actual: error
m2(ThisTestClass::foo); // expected: error; actual: ok
}
javac does nothing with any type parameters in the signatures, and should be updated.
interface F1 { <X> Object apply(X arg); }
interface F2 { <Y> String apply(Y arg); }
interface F3 { <X> Object apply(Object arg); }
interface F4 { String apply(Object arg); }
static void m1(F1 p) { System.out.println("F1"); }
static void m1(F2 f) { System.out.println("F2"); }
static void m2(F3 p) { System.out.println("F3"); }
static void m2(F4 f) { System.out.println("F4"); }
static String foo(Object in) { return "abc"; }
static void test(boolean cond) {
m1(ThisTestClass::foo); // expected: ok; actual: error
m2(ThisTestClass::foo); // expected: error; actual: ok
}
- relates to
-
JDK-8297158 Suspicious collection method call in Types.isSameTypeVisitor
-
- Resolved
-
-
JDK-8144767 Fix handling of capture variables in most-specific test
-
- Closed
-
-
JDK-8042285 15.12.2.5: Describe treatment of generic function types
-
- Closed
-