-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b46
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085306 | emb-9 | Maurizio Cimadamore | P4 | Resolved | Fixed | team |
The method resolution diagnostic simplification framework doesn't work with generic calls, even when the cause of the mismatch does not depend on inference variables:
<Z> void m(List<Z> z, List<String> ls) { }
void test(List<Integer> li) {
m(null, li);
}
error is this:
Main.java:6: error: method m in class Foo cannot be applied to given types;
m(null, li);
^
required: List<Z>,List<String>
found: <null>,List<Integer>
reason: cannot infer type-variable(s) Z
(argument mismatch; List<Integer> cannot be converted to List<String>)
where Z is a type-variable:
Z extends Object declared in method <Z>m(List<Z>,List<String>)
When it could have been simplified into something like:
Main.java:6: error: incompatible types: List<Integer> cannot be converted to List<String>
m(null, li);
^
Diamond related error messages also suffer from a similar issue.
<Z> void m(List<Z> z, List<String> ls) { }
void test(List<Integer> li) {
m(null, li);
}
error is this:
Main.java:6: error: method m in class Foo cannot be applied to given types;
m(null, li);
^
required: List<Z>,List<String>
found: <null>,List<Integer>
reason: cannot infer type-variable(s) Z
(argument mismatch; List<Integer> cannot be converted to List<String>)
where Z is a type-variable:
Z extends Object declared in method <Z>m(List<Z>,List<String>)
When it could have been simplified into something like:
Main.java:6: error: incompatible types: List<Integer> cannot be converted to List<String>
m(null, li);
^
Diamond related error messages also suffer from a similar issue.
- backported by
-
JDK-8085306 Javac misses some opportunities for diagnostic simplification
-
- Resolved
-