new inference: 18.5.2 adjustments

This commit is contained in:
Anna Kozlova
2014-02-18 19:19:49 +01:00
parent 61039804a9
commit bd681beb26
34 changed files with 125 additions and 91 deletions

View File

@@ -29,7 +29,7 @@ public class ConcurrentCollectors {
static <T, K, D, M1 extends Map<K, D>> C<T, M1> groupingBy(F<M1> f,
C<T, D> c,
BiConsumer<M1, T> consumer) {
return new CImpl<><error descr="'CImpl(ConcurrentCollectors.F<R>, ConcurrentCollectors.BiConsumer<R,T>, ConcurrentCollectors.BiOp<R>)' in 'ConcurrentCollectors.CImpl' cannot be applied to '(ConcurrentCollectors.F<M1>, ConcurrentCollectors.BiConsumer<M1,T>, ConcurrentCollectors.BiOp<ConcurrentCollectors.ConcurrentMap<java.lang.Object,D>>)'">(f, consumer, arg(c.getOp()))</error>;
return new CImpl<>(f, consumer, arg<error descr="'arg(ConcurrentCollectors.BiOp<V>)' in 'ConcurrentCollectors.Test3' cannot be applied to '(ConcurrentCollectors.BiOp<D>)'">(c.getOp())</error>);
}
static <K, V, M2 extends ConcurrentMap<K, V>> BiOp<M2> arg(BiOp<V> op) {

View File

@@ -21,7 +21,7 @@ class NoInferenceResult {
m((String s1) -> s1.length());
m((String s1) -> s1);
m1(<error descr="Target type of a lambda conversion must be an interface">() -> { }</error>);
m1<error descr="'m1(T)' in 'NoInferenceResult' cannot be applied to '(<lambda expression>)'">(() -> { })</error>;
Foo<String> foo = new Foo<String>();
foo.map(v -> null);

View File

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

View File

@@ -36,7 +36,7 @@ class Test1 {
if (s.equals("1")) {
return Option.option(1);
} else {
return Option.option<error descr="'option(java.lang.Integer)' in 'Test1.Option' cannot be applied to '(java.lang.String)'">("2")</error>;
return Option.option<error descr="'option(T)' in 'Test1.Option' cannot be applied to '(java.lang.String)'">("2")</error>;
}
};
}

View File

@@ -12,7 +12,7 @@ class TypeArgsConsistency {
I<Integer> i1 = (i, j) -> i + j;
foo((i, j) -> i + j);
I<Integer> i2 = bar((i, j) -> i + j);
I<Integer> i3 = bar(<error descr="Incompatible return type String in lambda expression">(i, j) -> "" + i + j</error>);
I<Integer> i3 = bar(<error descr="Cyclic inference">(i, j) -> "" + i + j</error>);
}
}
@@ -43,7 +43,7 @@ class TypeArgsConsistency2 {
I<Integer> i1 = bar(x -> x);
I1<Integer> i2 = bar1(x -> 1);
I2<String> aI2 = bar2(x -> "");
I2<Integer> aI28 = bar2( <error descr="Incompatible return type String in lambda expression">x-> ""</error>);
I2<Integer> aI28 = bar2( <error descr="Cyclic inference">x-> ""</error>);
I2<Integer> i3 = bar2(x -> x);
I2<Integer> i4 = bar2(x -> foooI());
System.out.println(i4.foo(2));

View File

@@ -14,7 +14,7 @@ class NoLambda {
static <T> T id(T i2) {return i2;}
{
id(<error descr="Target type of a lambda conversion must be an interface">() -> {System.out.println("hi");}</error>);
id<error descr="'id(T)' in 'NoLambda' cannot be applied to '(<lambda expression>)'">(() -> {System.out.println("hi");})</error>;
NoLambda.<Runnable>id(() -> {System.out.println("hi");});
}
}

View File

@@ -13,7 +13,7 @@ class Foo<R> {
public void foo() {
reduce(Moo::new);
reduce(<error descr="Cyclic inference">AMoo::new</error>);
<error descr="Inferred type 'Foo<R>.AMoo' for type parameter 'S' is not within its bound; should implement 'Foo.ASink<java.lang.Object,Foo<R>.AMoo>'">reduce(AMoo::new)</error>;
reduce(AAMoo::new);
reduce(AAAMoo::new);
}

View File

@@ -34,7 +34,7 @@ class Test1111 {
}
public void test(I<?> i) {
bar<error descr="'bar(Test1111.I<? super A>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
bar<error descr="'bar(Test1111.I<? super java.lang.Object>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
}
public static <A> void bar(I<? super A> i) {}

View File

@@ -9,7 +9,7 @@ class Test {
<R> SuperFoo<R> foo(I<R> ax) { return null; }
SuperFoo<String> ls = foo(() -> new Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'"></error>>());
SuperFoo<String> ls = foo(<error descr="Incompatible return type Foo<X> in lambda expression">() -> new Foo<>()</error>);
SuperFoo<Integer> li = foo(() -> new Foo<>());
SuperFoo<?> lw = foo(() -> new Foo<>());
}

View File

@@ -6,7 +6,7 @@ public class Bug
{
final I<CRN> f = null;
Bug.<String>create<error descr="'create(Bug.I<java.lang.String>)' in 'Bug' cannot be applied to '(Bug.I<CRN>)'">(fn(f))</error>;
Bug.<String>create(fn<error descr="'fn(Bug.I<FN>)' in 'Bug' cannot be applied to '(Bug.I<CRN>)'">(f)</error>);
return create(fn(f));

View File

@@ -15,4 +15,21 @@ class Test {
}
public static <C> void foo(Function<String, C> fn) { }
}
}
class Test1 {
interface Function<K> {
K _();
}
static {
foo(Test1::asList);
}
public static <T> List<T> asList(T... a) {
return null;
}
public static <C> void foo(Function<C> fn) { }
}