-
Bug
-
Resolution: Unresolved
-
P4
-
8
Per JLS 8 15.12.2.1, all lambdas and method references are considered potentially compatible with bare type arguments. But when there are explicit type arguments, javac appears to be substituting away the bare type argument before performing this check. This is incorrect. (The analysis is intentionally simple, avoiding things like subtyping and substitutions.)
public class ExplicitFunctionArg {
interface Sink<T> { void test(T arg); }
<T> void m(T arg, java.io.Serializable x) {}
<T> void m(Sink<T> arg, Cloneable x) {}
void test() {
this.<String>m(x -> {}, new int[0]);
// expected: ambiguity error; actual: no error
}
}
Reported by Jon Rafkind at lambda-spec-observers@openjdk.java.net.
public class ExplicitFunctionArg {
interface Sink<T> { void test(T arg); }
<T> void m(T arg, java.io.Serializable x) {}
<T> void m(Sink<T> arg, Cloneable x) {}
void test() {
this.<String>m(x -> {}, new int[0]);
// expected: ambiguity error; actual: no error
}
}
Reported by Jon Rafkind at lambda-spec-observers@openjdk.java.net.