new inference: use site substitution inside one level of inference only so calls with different site substitutions are possible in one expression (IDEA-131723; IDEA-131562)

This commit is contained in:
Anna Kozlova
2014-10-24 17:21:37 +02:00
parent a9bb3f4122
commit 5136167d8b
6 changed files with 125 additions and 45 deletions

View File

@@ -0,0 +1,49 @@
import java.util.Map;
import java.util.List;
//expected type parameter
class Sample<V> {
public <K> Map<V, K> test() {
return null;
}
public <T> void fun(T t, V v) {
}
<M> M bar() {
return null;
}
void run(Sample<Integer> sample) {
fun(test(), bar());
sample.fun(test(), sample.bar());
sample.fun(test(), bar());
fun(test(), sample.bar());
fun(sample.test(), bar());
fun(sample.test(), sample.bar());
sample.fun(sample.test(), bar());
sample.fun(sample.test(), sample.bar());
}
}
//expected generic type
class Sample1<T> {
public <S extends T> List<S> reverse() {
return null;
}
public void foo(Sample1<Comparable> t)
{
newTreeSet(t.reverse());
newTreeSet(reverse());
t.newTreeSet(t.reverse());
t.newTreeSet(reverse());
}
public <E> void newTreeSet(List<E> comparator) {}
}

View File

@@ -67,7 +67,7 @@ class MyTest1 {
}
public static void main(String[] args) {
m<error descr="Ambiguous method call: both 'MyTest1.m(I1)' and 'MyTest1.m(I2)' match">(Foo::new)</error>;
m<error descr="Ambiguous method call: both 'MyTest1.m(I2)' and 'MyTest1.m(I3)' match">(Foo::new)</error>;
}
}
class MyTest2 {
@@ -104,6 +104,6 @@ class MyTest2 {
}
public static void main(String[] args) {
m<error descr="Ambiguous method call: both 'MyTest2.m(I1)' and 'MyTest2.m(I2)' match">(Foo::new)</error>;
m<error descr="Ambiguous method call: both 'MyTest2.m(I2)' and 'MyTest2.m(I3)' match">(Foo::new)</error>;
}
}