-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
8
Potential compatibility testing takes into account the arity of the targeted function type, but not the number of type parameters. Specifically, given a lambda argument, it would be possible to treat as incompatible all target function types that are generic. (Per 15.27.3, a lambda is never compatible with a generic function type.)
Example:
interface ConsumerA { <T> void accept(int i); }
interface ConsumerB { void accept(int i); }
void execute1(ConsumerA c) {}
void execute1(ConsumerB c) {}
execute1(x -> {}); // specified ambiguous, but could be disambiguated
Example:
interface ConsumerA { <T> void accept(int i); }
interface ConsumerB { void accept(int i); }
void execute1(ConsumerA c) {}
void execute1(ConsumerB c) {}
execute1(x -> {}); // specified ambiguous, but could be disambiguated