inference: propagate variable renames through the call hierarchy; calculate tooltips in tests (IDEA-151948)

This commit is contained in:
Anna Kozlova
2016-02-22 20:05:58 +01:00
parent 792d40fc9f
commit 930df16f98
14 changed files with 73 additions and 18 deletions
@@ -3,7 +3,7 @@ import java.util.List;
class IdeaBugTest {
public void foo(List<Base> base) {
MyCollection.fun<error descr="'fun(java.util.List<? extends Base>, java.util.Comparator<? super Base>)' in 'MyCollection' cannot be applied to '(java.util.List<Base>, SubComparator)'">(base, new SubComparator())</error>;
MyCollection.fun(base, <error descr="'fun(java.util.List<? extends Base>, java.util.Comparator<? super Base>)' in 'MyCollection' cannot be applied to '(java.util.List<Base>, SubComparator)'">new SubComparator()</error>);
}
}
@@ -3,7 +3,7 @@ import java.util.Set;
class Test {
public static void test(Set foo, Matcher<Iterable<String>> matcher) {
assertThat<error descr="'assertThat(Test.Matcher<? super java.util.Set>, java.util.Set)' in 'Test' cannot be applied to '(Test.Matcher<java.lang.Iterable<java.lang.String>>, java.util.Set)'">(matcher, foo)</error>;
assertThat(<error descr="'assertThat(Test.Matcher<? super java.util.Set>, java.util.Set)' in 'Test' cannot be applied to '(Test.Matcher<java.lang.Iterable<java.lang.String>>, java.util.Set)'">matcher</error>, foo);
Matcher<Iterable<String>> b = null;
<error descr="Incompatible types. Found: 'Test.Matcher<java.lang.Iterable<java.lang.String>>', required: 'Test.Matcher<? super java.util.Set>'">Matcher<? super Set> a = b;</error>
@@ -5,6 +5,6 @@ abstract class X {
abstract <T> void copy(List<T> dest, List<? extends T> src);
void foo(List<?> x, List<?> y){
copy<error descr="'copy(java.util.List<capture<?>>, java.util.List<? extends capture<?>>)' in 'X' cannot be applied to '(java.util.List<capture<?>>, java.util.List<capture<?>>)'">(x, y)</error>;
copy(x, <error descr="'copy(java.util.List<capture<?>>, java.util.List<? extends capture<?>>)' in 'X' cannot be applied to '(java.util.List<capture<?>>, java.util.List<capture<?>>)'">y</error>);
}
}
@@ -2,7 +2,7 @@ class Test {
public void doesNotCompile() {
Container<String> container = new Container<String>();
assertThat<error descr="'assertThat(Test.Container<java.lang.String>, Test.Matcher<? super Test.Container<java.lang.String>>)' in 'Test' cannot be applied to '(Test.Container<java.lang.String>, Test.Matcher<Test.Container<capture<? super java.lang.String>>>)'">(container, hasSomething(is("foo")))</error>;
assertThat(container, <error descr="'assertThat(Test.Container<java.lang.String>, Test.Matcher<? super Test.Container<java.lang.String>>)' in 'Test' cannot be applied to '(Test.Container<java.lang.String>, Test.Matcher<Test.Container<capture<? super java.lang.String>>>)'">hasSomething(is("foo"))</error>);
}
public static class Container<T> {}
@@ -1,6 +1,6 @@
class D<T> {
void foo(D<?> x){
bar<error descr="'bar(D<?>, D<? super java.lang.Object>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
bar(x,<error descr="'bar(D<?>, D<? super java.lang.Object>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">x</error>);
}
<T> void bar(D<? extends T> x, D<? super T> y){}
}
@@ -7,7 +7,7 @@ class NestedGenericGoodCodeIsRed {
Number num = null;
satisfiesAllOf(isPositive(), isEqualTo(num));
this.<Number>satisfiesAllOf<error descr="'satisfiesAllOf(NestedGenericGoodCodeIsRed.Predicate<? super java.lang.Number>, NestedGenericGoodCodeIsRed.Predicate<? super java.lang.Number>)' in 'NestedGenericGoodCodeIsRed' cannot be applied to '(NestedGenericGoodCodeIsRed.Predicate<java.lang.Number>, NestedGenericGoodCodeIsRed.Predicate<java.lang.Integer>)'">(isPositive(), isEqualTo(10))</error>;
this.<Number>satisfiesAllOf(isPositive(), <error descr="'satisfiesAllOf(NestedGenericGoodCodeIsRed.Predicate<? super java.lang.Number>, NestedGenericGoodCodeIsRed.Predicate<? super java.lang.Number>)' in 'NestedGenericGoodCodeIsRed' cannot be applied to '(NestedGenericGoodCodeIsRed.Predicate<java.lang.Number>, NestedGenericGoodCodeIsRed.Predicate<java.lang.Integer>)'">isEqualTo(10)</error>);
}
@@ -61,7 +61,7 @@ class VarianceTesting {
class SuperTester <U> {
void go(Acceptor<? super U> acceptor, U u) {
acceptor.accept<error descr="'accept(SuperTester<capture<? super U>>, capture<? super U>)' in 'SuperTester.Acceptor' cannot be applied to '(SuperTester<U>, U)'">(this, u)</error>;
acceptor.accept(<error descr="'accept(SuperTester<capture<? super U>>, capture<? super U>)' in 'SuperTester.Acceptor' cannot be applied to '(SuperTester<U>, U)'">this</error>, u);
}
static class Acceptor <V> {
@@ -142,7 +142,7 @@ class S1 {
}
void bar(List<? extends S1> k) {
f<error descr="'f(java.util.List<capture<? extends S1>>, capture<? extends S1>)' in 'S1' cannot be applied to '(java.util.List<capture<? extends S1>>, S1)'">(k, k.get(0))</error>;
f(k, <error descr="'f(java.util.List<capture<? extends S1>>, capture<? extends S1>)' in 'S1' cannot be applied to '(java.util.List<capture<? extends S1>>, S1)'">k.get(0)</error>);
}
}
@@ -152,7 +152,7 @@ class S2 {
}
void bar(List<? extends S2> k) {
f<error descr="'f(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
f(k, <error descr="'f(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">k</error>);
}
}
@@ -214,7 +214,7 @@ public static void foo(List<? extends Foo> foos) {
class OtherBug1 {
public static void foo(List<? super Foo> foos) {
final Comparator<Foo> comparator = createComparator();
Collections.sort<error descr="'sort(java.util.List<capture<? super OtherBug1.Foo>>, java.util.Comparator<? super capture<? super OtherBug1.Foo>>)' in 'java.util.Collections' cannot be applied to '(java.util.List<capture<? super OtherBug1.Foo>>, java.util.Comparator<OtherBug1.Foo>)'">(foos, comparator)</error>;
Collections.sort(foos, <error descr="'sort(java.util.List<capture<? super OtherBug1.Foo>>, java.util.Comparator<? super capture<? super OtherBug1.Foo>>)' in 'java.util.Collections' cannot be applied to '(java.util.List<capture<? super OtherBug1.Foo>>, java.util.Comparator<OtherBug1.Foo>)'">comparator</error>);
}
private static Comparator<Foo> createComparator() {