isApplicability check based on pertinentToApplicability

This commit is contained in:
Anna Kozlova
2015-11-30 15:02:29 +01:00
parent d84e18ec58
commit 621795bbee
24 changed files with 47 additions and 33 deletions

View File

@@ -3,10 +3,10 @@ import java.util.Map;
class Test {
public static void main(String[] args) {
<error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.lang.Object>'">Map<Object, Object> b = newMapTrie();</error>
<error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>'">Map<Object, Map<Object, Object>> c = newMapTrie();</error>
<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>>>'">Map<Object, Map<Object, Map<Object, Object>>> d = newMapTrie();</error>
<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>>>>'">Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> e = newMapTrie();</error>
Map<Object, Object> b = newMapTrie<error descr="'newMapTrie()' in 'Test' cannot be applied to '()'">()</error>;
Map<Object, Map<Object, Object>> c = newMapTrie<error descr="'newMapTrie()' in 'Test' cannot be applied to '()'">()</error>;
Map<Object, Map<Object, Map<Object, Object>>> d = newMapTrie<error descr="'newMapTrie()' in 'Test' cannot be applied to '()'">()</error>;
Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> e = newMapTrie<error descr="'newMapTrie()' in 'Test' cannot be applied to '()'">()</error>;
}
public static <T extends Map<Byte, T>> T newMapTrie() {

View File

@@ -6,8 +6,8 @@ class Issue {
public static void main(String[] args) {
consume(get());
consume<error descr="Cannot resolve method 'consume(java.io.Serializable)'">(getSerizalizable())</error>;
consume<error descr="Cannot resolve method 'consume(java.lang.Object)'">(getObject())</error>;
consume<error descr="Ambiguous method call: both 'Issue.consume(Issue...)' and 'Issue.consume(Collection)' match">(getSerizalizable())</error>;
consume<error descr="Ambiguous method call: both 'Issue.consume(Issue...)' and 'Issue.consume(Collection)' match">(getObject())</error>;
}
public static <T extends Issue> T get() {

View File

@@ -8,7 +8,7 @@ class Test {
{
m(foo());
m<error descr="Cannot resolve method 'm(java.lang.Object)'">(bar())</error>;
m<error descr="Ambiguous method call: both 'Test.m(Runnable)' and 'Test.m(List<Runnable>)' match">(bar())</error>;
}
<T> List<T> foo() {

View File

@@ -20,7 +20,7 @@ public class Test<A, B extends Number> {
public static void main(String[] args) {
Inner<Number, Double> inn = new Inner<>();
inn.<error descr="Ambiguous method call: both 'Inner.m8(IO<? extends Number>)' and 'Inner.m8(IN<? extends Double>)' match">m8</error>(p -> 1.0);
new Test<Number, Integer>().<error descr="Cannot resolve method 'foo(<lambda expression>)'">foo</error>(p -> 1.0);
new Test<Number, Integer>().<error descr="Ambiguous method call: both 'Test.foo(IO<? extends Number>)' and 'Test.foo(IN<? extends Integer>)' match">foo</error>(p -> 1.0);
}
}

View File

@@ -8,7 +8,7 @@ class Test {
IntStream mi = sp.map(Inner::foo);
Stream<Integer> mI = sp.map(Inner::fooBoxed);
IntStream li = sp.<error descr="Cannot resolve method 'map(<lambda expression>)'">map</error>(inner->inner.<error descr="Cannot resolve method 'foo()'">foo</error>());
IntStream li = sp.<error descr="Ambiguous method call: both 'Stream.map(Function<? super Inner, ? extends R>)' and 'Stream.map(IntFunction<? super Inner>)' match">map</error>(inner->inner.<error descr="Cannot resolve method 'foo()'">foo</error>());
Stream<Integer> lI = sp.<error descr="Ambiguous method call: both 'Stream.map(Function<? super Inner, ? extends Integer>)' and 'Stream.map(IntFunction<? super Inner>)' match">map</error>(inner -> inner.<error descr="Cannot resolve method 'fooBoxed()'">fooBoxed</error>());
}

View File

@@ -25,7 +25,7 @@ class ReturnTypeIncompatibility {
}
public static void main(String[] args) {
<error descr="Cannot resolve method 'call(<lambda expression>)'">call</error>(i-> {return i;});
<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<Integer>)' and 'ReturnTypeIncompatibility.call(I2<P>)' match">call</error>(i-> {return i;});
}
}
@@ -57,7 +57,7 @@ class ReturnTypeCompatibility {
}
public static void main(String[] args) {
<error descr="Cannot resolve method 'call(<lambda expression>)'">call</error>(i-> {return i;});
<error descr="Ambiguous method call: both 'ReturnTypeCompatibility.call(I1<Number>)' and 'ReturnTypeCompatibility.call(I2<P>)' match">call</error>(i-> {return i;});
}
}

View File

@@ -21,9 +21,9 @@ class Test {
}
void foo(Foo<String> as, final Foo<Character> ac) {
boolean b1 = as.<error descr="Ambiguous method call: both 'Foo.forAll(I<String, Boolean>)' and 'Foo.forAll(II<String, String>)' match">forAll</error>(s -> ac.<error descr="Cannot resolve method 'forAll(<lambda expression>)'">forAll</error>(c -> false));
String s1 = as.<error descr="Ambiguous method call: both 'Foo.forAll(I<String, Boolean>)' and 'Foo.forAll(II<String, String>)' match">forAll</error>(s -> ac.<error descr="Cannot resolve method 'forAll(<lambda expression>)'">forAll</error>(c -> ""));
boolean b2 = as.<error descr="Ambiguous method call: both 'Foo.forAll(I<String, Boolean>)' and 'Foo.forAll(II<String, String>)' match">forAll</error>(s -> ac.<error descr="Cannot resolve method 'forAll(<lambda expression>)'">forAll</error>(c -> ""));
boolean b1 = as.<error descr="Ambiguous method call: both 'Foo.forAll(I<String, Boolean>)' and 'Foo.forAll(II<String, String>)' match">forAll</error>(s -> ac.<error descr="Ambiguous method call: both 'Foo.forAll(I<Character, Boolean>)' and 'Foo.forAll(II<Character, String>)' match">forAll</error>(c -> false));
String s1 = as.<error descr="Ambiguous method call: both 'Foo.forAll(I<String, Boolean>)' and 'Foo.forAll(II<String, String>)' match">forAll</error>(s -> ac.<error descr="Ambiguous method call: both 'Foo.forAll(I<Character, Boolean>)' and 'Foo.forAll(II<Character, String>)' match">forAll</error>(c -> ""));
boolean b2 = as.<error descr="Ambiguous method call: both 'Foo.forAll(I<String, Boolean>)' and 'Foo.forAll(II<String, String>)' match">forAll</error>(s -> ac.<error descr="Ambiguous method call: both 'Foo.forAll(I<Character, Boolean>)' and 'Foo.forAll(II<Character, String>)' match">forAll</error>(c -> ""));
String s2 = as.forAll2(s -> ac.forAll2(c -> <error descr="Bad return type in lambda expression: boolean cannot be converted to String">false</error>));
boolean b3 = as.forAll((I<String, Boolean>)s -> ac.forAll((I<Character, Boolean>)c -> <error descr="Bad return type in lambda expression: String cannot be converted to Boolean">""</error>));
String s3 = as.forAll((II<String, String>)s -> ac.forAll((II<Character, String>)c -> <error descr="Bad return type in lambda expression: boolean cannot be converted to String">false</error>));

View File

@@ -9,6 +9,6 @@ class Calls {
void foo(Function<String, Optional> computable) {}
{
((x) -> a(b(c<error descr="'c(C)' in 'Calls' cannot be applied to '(<lambda parameter>)'">(x)</error>)));
<error descr="Not a statement">((x) -> a(b(c(x))));</error>
}
}

View File

@@ -21,7 +21,7 @@ class MyTestDefaultConstructor {
private static void <warning descr="Private method 'foo(MyTestDefaultConstructor.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
foo<error descr="Cannot resolve method 'foo(<method reference>)'">(Foo::new)</error>;
foo<error descr="Ambiguous method call: both 'MyTestDefaultConstructor.foo(I1)' and 'MyTestDefaultConstructor.foo(I2)' match">(Foo::new)</error>;
}
}
@@ -49,7 +49,7 @@ class MyTestConstructor {
private static void <warning descr="Private method 'foo(MyTestConstructor.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
foo<error descr="Cannot resolve method 'foo(<method reference>)'">(Foo::new)</error>;
foo<error descr="Ambiguous method call: both 'MyTestConstructor.foo(I1)' and 'MyTestConstructor.foo(I2)' match">(Foo::new)</error>;
}
}
@@ -78,6 +78,6 @@ class MyTestMethod {
private static void <warning descr="Private method 'foo(MyTestMethod.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
foo<error descr="Cannot resolve method 'foo(<method reference>)'">(MyTestMethod::m)</error>;
foo<error descr="Ambiguous method call: both 'MyTestMethod.foo(I1)' and 'MyTestMethod.foo(I2)' match">(MyTestMethod::m)</error>;
}
}

View File

@@ -20,7 +20,7 @@ class MyTest {
static void foo(I3 i) {}
static {
foo<error descr="Cannot resolve method 'foo(<method reference>)'">(MyTest::m)</error>;
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(MyTest::m)</error>;
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(MyTest::m1)</error>;
}
}

View File

@@ -39,6 +39,6 @@ class MyTest1 {
static void foo(I3 i) {}
static {
foo<error descr="Cannot resolve method 'foo(<method reference>)'">(Foo::new)</error>;
foo<error descr="Ambiguous method call: both 'MyTest1.foo(I1)' and 'MyTest1.foo(I2)' match">(Foo::new)</error>;
}
}

View File

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

View File

@@ -12,7 +12,7 @@ class MS {
void test(boolean cond) {
m(cond ? () -> 26 : () -> 24);
<error descr="Cannot resolve method 'm(?)'">m</error>(cond ? () -> 26 : () -> new Integer(42));
<error descr="Ambiguous method call: both 'MS.m(GetInt)' and 'MS.m(GetInteger)' match">m</error>(cond ? () -> 26 : () -> new Integer(42));
m(cond ? () -> new Integer(26) : () -> new Integer(42));
}
}

View File

@@ -3,7 +3,7 @@ import java.util.function.Supplier;
class Test {
public static void main(String... args) {
<error descr="Cannot resolve method 'c(<lambda expression>, <lambda expression>)'">c</error>(() -> 3, () -> 10);
<error descr="Ambiguous method call: both 'Test.c(Supplier<Integer>, Supplier<Integer>)' and 'Test.c(Supplier<T>, T)' match">c</error>(() -> 3, () -> 10);
}
public static <T> void c(Supplier<T> s1, Supplier<T> s2) {}

View File

@@ -32,12 +32,12 @@ class Test {
meth1(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
meth2(Foo::new);
meth3(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
meth4<error descr="Cannot resolve method 'meth4(<method reference>)'">(Foo::new)</error>;
meth4<error descr="Ambiguous method call: both 'Test.meth4(I1)' and 'Test.meth4(I2)' match">(Foo::new)</error>;
meth1(Test::<error descr="Cannot resolve method 'foo'">foo</error>);
meth2(Test::foo);
meth3(Test::<error descr="Cannot resolve method 'foo'">foo</error>);
meth4<error descr="Cannot resolve method 'meth4(<method reference>)'">(Test::foo)</error>;
meth4<error descr="Ambiguous method call: both 'Test.meth4(I1)' and 'Test.meth4(I2)' match">(Test::foo)</error>;
}

View File

@@ -11,7 +11,7 @@ class Test {
}
void test(boolean cond) {
<error descr="Cannot resolve method 'm(<lambda expression>)'">m</error>(() -> {
<error descr="Ambiguous method call: both 'Test.m(GetInt)' and 'Test.m(GetInteger)' match">m</error>(() -> {
if (cond)
return 42;
else

View File

@@ -12,6 +12,6 @@ abstract class PertinentToApplicabilityOfExplicitlyTypedLambdaTest {
abstract void foo(B b);
{
<error descr="Cannot resolve method 'foo(<lambda expression>)'">foo</error>(x -> y -> 42);
<error descr="Ambiguous method call: both 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(A)' and 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(B)' match">foo</error>(x -> y -> 42);
}
}