java highlighting: provide better incompatible types message on failed inference

GitOrigin-RevId: 5f97ec808f753d9ca40c417704ec93a802512745
This commit is contained in:
Anna Kozlova
2019-07-08 10:43:57 +02:00
committed by intellij-monorepo-bot
parent 6a7856d5c6
commit afa0706bfc
28 changed files with 87 additions and 101 deletions

View File

@@ -3,14 +3,10 @@ import java.util.Map;
class Test {
public static void main(String[] args) {
Map<Object, Object> b = <error descr="Incompatible types. Required Map<Object, Object> but 'newMapTrie' was inferred to T:
Incompatible equality constraint: Byte and Object">newMapTrie();</error>
Map<Object, Map<Object, Object>> c = <error descr="Incompatible types. Required Map<Object, Map<Object, Object>> but 'newMapTrie' was inferred to T:
Incompatible equality constraint: Byte and Object">newMapTrie();</error>
Map<Object, Map<Object, Map<Object, Object>>> d = <error descr="Incompatible types. Required Map<Object, Map<Object, Map<Object, Object>>> but 'newMapTrie' was inferred to T:
Incompatible equality constraint: Byte and Object">newMapTrie();</error>
Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> e = <error descr="Incompatible types. Required Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> but 'newMapTrie' was inferred to T:
Incompatible equality constraint: Byte and Object">newMapTrie();</error>
Map<Object, Object> b = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.lang.Object>'">newMapTrie();</error>
Map<Object, Map<Object, Object>> c = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>'">newMapTrie();</error>
Map<Object, Map<Object, Map<Object, Object>>> d = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>'">newMapTrie();</error>
Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> e = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>>'">newMapTrie();</error>
}
public static <T extends Map<Byte, T>> T newMapTrie() {

View File

@@ -6,8 +6,7 @@ class Test {
Factory factory = new Factory();
final Class<? extends ClassB> bClass = null;
ClassB b = factory.create(bClass);
String str = <error descr="Incompatible types. Required String but 'create' was inferred to T:
no instance(s) of type variable(s) exist so that capture of ? extends ClassB conforms to String">factory.create(bClass);</error>
String str = <error descr="Incompatible types. Found: 'capture<? extends Test.ClassB>', required: 'java.lang.String'">factory.create(bClass);</error>
}
public static class Factory {

View File

@@ -6,9 +6,7 @@ class Test {
}
void m(List l){
boolean foo = <error descr="Incompatible types. Required boolean but 'foo' was inferred to T:
Incompatible types: Object is not convertible to boolean">foo(l);</error>
String s = <error descr="Incompatible types. Required String but 'foo' was inferred to T:
Incompatible types: Object is not convertible to String">foo(l);</error>
boolean foo = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'boolean'">foo(l);</error>
String s = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">foo(l);</error>
}
}