do not open captured wildcards on substitution; don't capture wildcards on getExtendsTypes for type parameters and their consequences

This commit is contained in:
Anna Kozlova
2015-12-02 10:14:45 +01:00
parent b9990696d3
commit 3a669178f5
27 changed files with 84 additions and 91 deletions

View File

@@ -17,7 +17,7 @@ class Test2 {
int foo();
}
{
IntReturnType aI = () -> <error descr="Bad return type in lambda expression: void cannot be converted to int">System.out.println()</error>;
<error descr="Incompatible types. Found: '<lambda expression>', required: 'Test2.IntReturnType'">IntReturnType aI = () -> System.out.println();</error>
IntReturnType aI1 = () -> {System.out.println();<error descr="Missing return statement">}</error>;
IntReturnType aI2 = () -> {return 1;};
IntReturnType aI3 = () -> 1;
@@ -31,7 +31,7 @@ class Test3 {
X foo();
}
{
XReturnType<Object> aI = () -> <error descr="Bad return type in lambda expression: void cannot be converted to Object">System.out.println()</error>;
<error descr="Incompatible types. Found: '<lambda expression>', required: 'Test3.XReturnType<java.lang.Object>'">XReturnType<Object> aI = () -> System.out.println();</error>
XReturnType<Object> aI1 = () -> {System.out.println();<error descr="Missing return statement">}</error>;
XReturnType<Object> aI2 = () -> {return 1;};
XReturnType<Object> aI3 = () -> 1;
@@ -47,10 +47,10 @@ class Test4 {
}
{
YXReturnType<Object> aI = () -> <error descr="Bad return type in lambda expression: void cannot be converted to Test4.Y<Object>">System.out.println()</error>;
<error descr="Incompatible types. Found: '<lambda expression>', required: 'Test4.YXReturnType<java.lang.Object>'">YXReturnType<Object> aI = () -> System.out.println();</error>
YXReturnType<Object> aI1 = () -> {System.out.println();<error descr="Missing return statement">}</error>;
YXReturnType<Object> aI2 = () -> {return <error descr="Bad return type in lambda expression: int cannot be converted to Test4.Y<Object>">1</error>;};
YXReturnType<Object> aI3 = () -> <error descr="Bad return type in lambda expression: int cannot be converted to Test4.Y<Object>">1</error>;
<error descr="Incompatible types. Found: '<lambda expression>', required: 'Test4.YXReturnType<java.lang.Object>'">YXReturnType<Object> aI2 = () -> {return 1;};</error>
<error descr="Incompatible types. Found: '<lambda expression>', required: 'Test4.YXReturnType<java.lang.Object>'">YXReturnType<Object> aI3 = () -> 1;</error>
YXReturnType<Object> aI4 = () -> new Y<Object>(){};
YXReturnType<Object> aIDiamond = () -> new Y<>();

View File

@@ -68,5 +68,5 @@ class ReturnTypeChecks1 {
}
I<Integer, Integer> accepted = i -> { return i; };
I<Double, Integer> rejected = i -> { return <error descr="Bad return type in lambda expression: Double cannot be converted to Integer">i</error>; };
<error descr="Incompatible types. Found: '<lambda expression>', required: 'ReturnTypeChecks1.I<java.lang.Double,java.lang.Integer>'">I<Double, Integer> rejected = i -> { return i; };</error>
}

View File

@@ -24,8 +24,8 @@ class Test {
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>));
String s2 = as.forAll2(s -> ac.forAll2<error descr="'forAll2(Test.II<java.lang.Character,java.lang.String>)' in 'Test.Foo' cannot be applied to '(<lambda expression>)'">(c -> false)</error>);
boolean b3 = as.forAll((I<String, Boolean>)s -> ac.forAll(<error descr="Inconvertible types; cannot cast '<lambda expression>' to 'Test.I<java.lang.Character,java.lang.Boolean>'">(I<Character, Boolean>)c -> ""</error>));
String s3 = as.forAll((II<String, String>)s -> ac.forAll(<error descr="Inconvertible types; cannot cast '<lambda expression>' to 'Test.II<java.lang.Character,java.lang.String>'">(II<Character, String>)c -> false</error>));
}
}

View File

@@ -32,7 +32,7 @@ class Test1 {
I<Object> lO = x->x;
bar2("", lO);
I<String> lS = x-><error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x</error>;
<error descr="Incompatible types. Found: '<lambda expression>', required: 'Test1.I<java.lang.String>'">I<String> lS = x->x;</error>
bar2("", lS);
bar2("", x -> x);

View File

@@ -7,7 +7,7 @@ interface I<T>{
class C {
void bar(I<?> x) {
x.foo(a -> {
x.foo(y -> <error descr="Bad return type in lambda expression: capture of ? cannot be converted to capture of ?">a</error>);
x.foo<error descr="'foo(java.util.function.Function<capture<?>,capture<?>>)' in 'I' cannot be applied to '(<lambda expression>)'">(y -> a)</error>;
return a;
});
}