switch tests on new inference

(cherry picked from commit d2cbf3f2833104c3a0381059b0d6ef8ac0b3c94c)
This commit is contained in:
anna
2013-11-15 18:33:16 +01:00
parent 23432e3cd7
commit 481bc252f3
44 changed files with 698 additions and 32 deletions

View File

@@ -16,6 +16,7 @@ public class Autoboxing {
{
Object data = 1;
boolean is1 = <error descr="Operator '==' cannot be applied to 'java.lang.Object', 'int'">data == 1</error>;
boolean is2 = <error descr="Operator '==' cannot be applied to 'int', 'java.lang.Object'">1 == data</error>;
}
//IDEADEV-5549: Short and double are convertible

View File

@@ -4,7 +4,7 @@ public class FooBar1 {
{
Object x = null;
Object y = (CharSequence & Serializable) x;
Object y2 = (CharSequence & Integer) x;
Object y2 = (CharSequence & <error descr="Interface expected here">Integer</error>) x;
Object y3 = (Integer & CharSequence) x;
<error descr="Incompatible types. Found: 'java.lang.CharSequence & java.io.Serializable', required: 'int'">int y1 = (CharSequence & Serializable) x;</error>
}

View File

@@ -0,0 +1,14 @@
import java.util.*;
interface A2{};
interface B extends A2{};
class GenericTest {
public static <M extends V, V> List<V> convert(List<M> list){
return new ArrayList<V>();
}
public static void test(){
// it prompts convert returns List<B>
List<A2> as = convert(new ArrayList<B>());
}
}

View File

@@ -3,6 +3,6 @@ abstract class A<T>{
<S extends Number & Comparable<?>> void baz(A<S> a){}
void bar(A<Long> x, A<Integer> y){
baz<error descr="'baz(A<S>)' in 'A' cannot be applied to '(A<capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>>)'">(foo(x, y))</error>;
baz<error descr="'baz(A<java.lang.Number & java.lang.Comparable<?>>)' in 'A' cannot be applied to '(A<capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>>)'">(foo(x, y))</error>;
}
}

View File

@@ -87,7 +87,7 @@ class CaptureTest {
}
void foo (Class<? extends Emum<CaptureTest>> clazz) {
Emum.valueOf<error descr="'valueOf(java.lang.Class<T>, java.lang.String)' in 'CaptureTest.Emum' cannot be applied to '(java.lang.Class<capture<? extends CaptureTest.Emum<CaptureTest>>>, java.lang.String)'">(clazz, "CCC")</error>;
<error descr="Inferred type 'capture<? extends CaptureTest.Emum<CaptureTest>>' for type parameter 'T' is not within its bound; should extend 'CaptureTest.Emum<capture<? extends CaptureTest.Emum<CaptureTest>>>'">Emum.valueOf(clazz, "CCC")</error>;
}
}
@@ -182,7 +182,7 @@ class TypeBug {
multiList.add(intHolder);
multiList.add(doubleHolder);
swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<T>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<java.lang.Object>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
// this line causes a ClassCastException when checked.
Integer value = intHolder.value;

View File

@@ -5,7 +5,7 @@ class Test {
<K extends Throwable> void foo(F<K> f) throws K { }
{
<error descr="Unhandled exception: java.lang.Throwable">foo((t)->{});</error>
foo((t)->{});
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo((ClassNotFoundException t)->{});</error>
}
}

View File

@@ -1,11 +1,13 @@
class Test {
import java.io.IOException;
class Test {
interface F<T extends Throwable> {
void _() throws T;
}
void m1() { }
void m2() throws NullPointerException{ }
void m3() throws IOException { }
<K extends Throwable> void foo(F<K> f) throws K { }
{
@@ -14,6 +16,7 @@ class Test {
foo(this::m1);
foo(this::m2);
<error descr="Unhandled exception: java.io.IOException">foo(this::m3);</error>
}
}

View File

@@ -5,6 +5,6 @@ class Test {
<K extends ClassNotFoundException> void foo(F<K> f) throws K { }
{
<error descr="Unhandled exception: K">foo(() -> {});</error>
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo(() -> {});</error>
}
}

View File

@@ -12,18 +12,18 @@ class Test {
<K extends ClassNotFoundException> void foo2(F<K> f) throws K { }
{
<error descr="Inferred type 'java.lang.RuntimeException' for type parameter 'K' is not within its bound; should extend 'java.lang.ClassNotFoundException'">foo2(()->{})</error>;
foo2(()->{ <error descr="Unhandled exception: java.lang.ClassNotFoundException">throw new ClassNotFoundException();</error> });
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo2(()->{});</error>
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo2(()->{ throw new ClassNotFoundException(); });</error>
<error descr="Inferred type 'java.lang.RuntimeException' for type parameter 'K' is not within its bound; should extend 'java.lang.ClassNotFoundException'">foo2(this::m1)</error>;
foo2(<error descr="Unhandled exception: java.lang.ClassNotFoundException">this::m2</error>);
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo2(this::m1);</error>
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo2(this::m2);</error>
foo1(()->{ <error descr="Unhandled exception: java.lang.ClassNotFoundException">throw new ClassNotFoundException();</error> });
foo1(()->{ <error descr="Unhandled exception: java.lang.Exception">throw new Exception();</error> });
foo1(<error descr="Unhandled exception: java.lang.ClassNotFoundException">this::m2</error>);
foo1(<error descr="Unhandled exception: java.lang.Exception">this::m3</error>);
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo1(this::m2);</error>
<error descr="Unhandled exception: java.lang.Exception">foo1(this::m3);</error>
}
}

View File

@@ -0,0 +1,16 @@
public class Test<E_OUT> {
final <P_IN_WRAP_SINK> Sink<P_IN_WRAP_SINK> wrapSink(Sink<E_OUT> sink) {
return null;
}
final <P_IN> void wrapAndCopyInto( Sink<E_OUT> sink, Spliterator<P_IN> spliterator) {
copyInto(wrapSink(sink), spliterator);
}
final <P_IN_COPY> void copyInto(Sink<P_IN_COPY> wrappedSink, Spliterator<P_IN_COPY> spliterator) {
}
class Sink<T> {}
interface Spliterator<A>{}
}

View File

@@ -0,0 +1,15 @@
import java.util.List;
abstract class CollectionsExamples<T> {
private List<T> getEvenL() {
return collect( toList());
}
static <TT> Collector<?, List<TT>> toList() {
return null;
}
abstract <R, A> R collect(Collector<A, R> collector);
interface Collector<A, R> {}
}

View File

@@ -0,0 +1,17 @@
import java.util.*;
public class TestInfer
{
static <V, T extends V> List<V> singleton(T item)
{
ArrayList<V> list = new ArrayList<>();
list.add(item);
return list;
}
public List<Number> test()
{
List<Number> ln = singleton(new Long(1));
return singleton(new Long(2));
}
}

View File

@@ -6,4 +6,14 @@ class Main {
Integer i = 1;
long l2 = foo(foo(i));
}
}
}
class Main1 {
static <T> T foo(long t) { return null;}
static <B> B bar(B t) { return null;}
static {
long l = foo(bar(1));
}
}

View File

@@ -0,0 +1,16 @@
class Optional<T> {}
interface TerminalOp<E_IN, R> {}
abstract class AbstractPipeline<E_OUT>{
abstract void evaluate();
abstract <R> R evaluate(TerminalOp<E_OUT, R> terminalOp);
public final Optional<E_OUT> findFirst() {
return evaluate( makeRef(true));
}
public static <T> TerminalOp<T, Optional<T>> makeRef(boolean mustFindFirst) {
return null;
}
}

View File

@@ -3,5 +3,5 @@ import java.util.Map;
public class SOE {
public static <K extends M, M extends Map<K,M>> M foo() {return null;}
public static <K1 extends M1, M1 extends Map<K1,M1>> Map<K1, M1> foo1() {return <error descr="Inferred type 'java.util.Map<K1,M1>' for type parameter 'M' is not within its bound; should implement 'java.util.Map<K1,java.util.Map<K1,M1>>'">foo()</error>;}
public static <K1 extends M1, M1 extends Map<K1,M1>> Map<K1, M1> foo1() {return <error descr="Inferred type 'java.util.Map<K1,M1>' for type parameter 'M' is not within its bound; should implement 'java.util.Map<java.util.Map<K1,M1>,java.util.Map<K1,M1>>'">foo()</error>;}
}

View File

@@ -21,7 +21,7 @@ class NoInferenceResult {
m((String s1) -> s1.length());
m((String s1) -> s1);
m1<error descr="'m1(T)' in 'NoInferenceResult' cannot be applied to '(<lambda expression>)'">(() -> { })</error>;
m1(<error descr="Target type of a lambda conversion must be an interface">() -> { }</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<String & Integer>)' match">(i-> {return i;})</error>;
call<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<Integer>)' and 'ReturnTypeIncompatibility.call(I3<Object>)' match">(i-> {return i;})</error>;
}
}
@@ -57,7 +57,7 @@ class ReturnTypeCompatibility {
}
public static void main(String[] args) {
call<error descr="Ambiguous method call: both 'ReturnTypeCompatibility.call(I1)' and 'ReturnTypeCompatibility.call(I2)' match">(i-> {return i;})</error>;
call<error descr="Ambiguous method call: both 'ReturnTypeCompatibility.call(I1<Number>)' and 'ReturnTypeCompatibility.call(I2<String>)' match">(i-> {return i;})</error>;
}
}

View File

@@ -32,13 +32,13 @@ class Test1 {
}
};
Extractor<String, Integer> e1 = <error descr="Incompatible return type Option<String> in lambda expression">s -> {
Extractor<String, Integer> e1 = s -> {
if (s.equals("1")) {
return Option.option(1);
} else {
return Option.option("2");
return Option.option<error descr="'option(java.lang.Integer)' in 'Test1.Option' cannot be applied to '(java.lang.String)'">("2")</error>;
}
}</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);
<error descr="Incompatible types. Found: 'TypeArgsConsistency.I<java.lang.String>', required: 'TypeArgsConsistency.I<java.lang.Integer>'">I<Integer> i3 = bar((i, j) -> "" + i + j);</error>
I<Integer> i3 = bar(<error descr="Incompatible return type String in lambda expression">(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 -> "");
<error descr="Incompatible types. Found: 'TypeArgsConsistency2.I2<java.lang.String>', required: 'TypeArgsConsistency2.I2<java.lang.Integer>'">I2<Integer> aI28 = bar2( x-> "");</error>
I2<Integer> aI28 = bar2( <error descr="Incompatible return type String in lambda expression">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="'id(T)' in 'NoLambda' cannot be applied to '(<lambda expression>)'">(() -> {System.out.println("hi");})</error>;
id(<error descr="Target type of a lambda conversion must be an interface">() -> {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="'reduce(Foo.Factory<Foo.ASink>)' in 'Foo' cannot be applied to '(<method reference>)'">(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

@@ -27,7 +27,7 @@ class MyTest<E> {
bar(MyTest<String>::new, "");
bar(MyTest::new, "");
bar(<error descr="Cyclic inference">MyTest::new</error>);
bar(<error descr="Cyclic inference">MyTest<String>::new</error>);
bar(MyTest::new);
bar(MyTest<String>::new);
}
}

View File

@@ -5,7 +5,7 @@ class Test {
static void test() {
Integer next = map(String::length).iterator().next();
Integer next1 = map(Test::length).iterator().next();
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.Integer'">Integer next1 = map(Test::length).iterator().next();</error>
}
public static <T> T length(T s) {

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

@@ -0,0 +1,20 @@
abstract class AbstractPip {
interface Getter<T> {
T get();
}
interface Unbounded<K> {}
abstract <P_IN> void wrap(Getter<Unbounded<P_IN>> getter);
public void spliterator() {
wrap(() -> getUnbound());
}
private Unbounded<? extends String> getUnbound() {
return null;
}
}

View File

@@ -0,0 +1,31 @@
class CyclicInference {
interface Execute {
void execute();
}
/**
* Lambda wrapper for expression-like lambdas
*
* @param lambda
* @param <I> interface which lambda class implements (derived by compiler via type inference)
* @param <T> lambda class having function code to be executed
* @return I interface implemented by lambda
*/
private static <I, T extends I> I lambdaWrapper(final T lambda) {
return (I)lambda;
}
/**
* How expression-like lambdas returning void can be wrapped
*/
public void lambdaWithOneExpressionReturningVoid() {
Execute sayHello = lambdaWrapper(() -> System.out.println("Hello"));
sayHello.execute();
}
public static void main(String[] args) {
CyclicInference lam = new CyclicInference();
lam.lambdaWithOneExpressionReturningVoid();
}
}

View File

@@ -0,0 +1,86 @@
class BugExample {
public static void main(String... args) {
Observable<String> obs = create((Observer<? super String> o) -> {
o.onNext("one");
o.onNext("two");
o.onCompleted();
});
obs.subscribe(new Observer<String>() {
@Override
public void onCompleted() {
System.out.println("Completed");
}
@Override
public void onError(Throwable e) {
System.out.println("Error");
}
@Override
public void onNext(String v) {
System.out.println("Value: " + v);
}
});
Observable<String> obs2 = create(new OnSubscribeFunc<String>() {
@Override
public void onSubscribe(Observer<? super String> o) {
o.onNext("one");
o.onNext("two");
o.onCompleted();
}
});
obs2.subscribe(new Observer<String>() {
@Override
public void onCompleted() {
System.out.println("Completed");
}
@Override
public void onError(Throwable e) {
System.out.println("Error");
}
@Override
public void onNext(String v) {
System.out.println("Value: " + v);
}
});
}
public static class Observable<T> {
private final OnSubscribeFunc<T> f;
public Observable(OnSubscribeFunc<T> f) {
this.f = f;
}
public void subscribe(Observer<T> o) {
f.onSubscribe(o);
}
}
public static <T> Observable<T> create(OnSubscribeFunc<T> func) {
return new Observable<T>(func);
}
public static interface OnSubscribeFunc<T> {
public void onSubscribe(Observer<? super T> t1);
}
public interface Observer<T> {
public void onCompleted();
public void onError(Throwable e);
public void onNext(T args);
}
}

View File

@@ -0,0 +1,21 @@
public class Tmp {
Integer toInt(Number num) {
return null;
}
Stream<Number> test() {
Stream<Number> numberStream = null;
Stream<Number> integerStream1 = numberStream.map(this::toInt);
Stream<Number> integerStream2 = numberStream.map(num -> toInt(num));
return numberStream.map(this::toInt);
}
}
interface Stream<T> {
<R> Stream<R> map(Function<? super T, ? extends R> mapper);
}
interface Function<I, R> {
R fun(I t);
}

View File

@@ -0,0 +1,17 @@
interface Eff<A, B> {
B f(A a);
}
class Disfunction {
public static <A, B, C> Eff<C, B> apply(final Eff<C, Eff<A, B>> cab, final Eff<C, A> ca) {
return bind(cab, f -> compose(a -> f.f(a), ca));
}
public static <A, B, C> Eff<C, B> bind(final Eff<C, A> ma, final Eff<A, Eff<C, B>> f) {
return m -> f.f(ma.f(m)).f(m);
}
public static <A, B, C> Eff<A, C> compose(final Eff<B, C> f, final Eff<A, B> g) {
return a -> f.f(g.f(a));
}
}

View File

@@ -0,0 +1,26 @@
import java.util.List;
import java.util.Map;
class Collector<C> {
}
interface Function<T, R> {
R apply(T t);
}
public final class Collectors {
public static <T>
Collector<List<T>> toList() {
return null;
}
public static <T1, K1> Collector<Map<K1, List<T1>>> groupingBy(Function<T1, K1> classifier) {
return groupingBy(classifier, toList());
}
public static <T, K, D> Collector<Map<K, D>> groupingBy(Function<T, K> classifier,
Collector<D> downstream) {
return null;
}
}

View File

@@ -0,0 +1,36 @@
import java.util.ArrayList;
import java.util.List;
class Collector<C> {
}
interface S<T> {
/**
* Gets a result.
*
* @return a result
*/
T get();
}
interface F<TF> {}
public final class Collectors {
public static <T>
Collector<List<T>> toList() {
return null;
}
public static <K1> Collector<ArrayList<K1>> groupingBy(F<K1> classifier) {
return groupingBy(classifier, ArrayList ::new);
}
public static <K, M extends ArrayList<K>>
Collector<M> groupingBy(F<K> classifier,
S<M> mapFactory) {
return null;
}
}

View File

@@ -0,0 +1,86 @@
class BBB {
static <T> void f() {
TerminalOp<T, LinkedHashSet<T>> <warning descr="Variable 'reduceOp' is never used">reduceOp</warning> = BBB.<T, LinkedHashSet<T>>makeRef(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
}
public static <T, U> TerminalOp<T, U> makeRef(U <warning descr="Parameter 'seed' is never used">seed</warning>, BiFunction<U, ? super T, U> <warning descr="Parameter 'reducer' is never used">reducer</warning>, BinaryOperator<U> <warning descr="Parameter 'combiner' is never used">combiner</warning>) {
return null;
}
public static <T, R> TerminalOp<T, R> makeRef(Supplier<R> <warning descr="Parameter 'seedFactory' is never used">seedFactory</warning>, BiConsumer<R, ? super T> <warning descr="Parameter 'accumulator' is never used">accumulator</warning>, BiConsumer<R,R> <warning descr="Parameter 'reducer' is never used">reducer</warning>) {
return null;
}
public static void main(String[] args) {
f();
}
}
interface Supplier<T> {
T get();
}
interface BiFunction<T, U, R> {
R apply(T t, U u);
}
interface BinaryOperator<T> extends BiFunction<T,T,T> {}
interface BiConsumer<T, U> {
void accept(T t, U u);
}
interface TerminalOp<<warning descr="Type parameter 'E_IN' is never used">E_IN</warning>, <warning descr="Type parameter 'R' is never used">R</warning>> {}
class LinkedHashSet<E> extends HashSet<E>{
public LinkedHashSet(int <warning descr="Parameter 'initialCapacity' is never used">initialCapacity</warning>, float <warning descr="Parameter 'loadFactor' is never used">loadFactor</warning>) {
}
public LinkedHashSet(int <warning descr="Parameter 'initialCapacity' is never used">initialCapacity</warning>) {
}
public LinkedHashSet() {
}
}
class HashSet<E> extends AbstractSet<E> {
public HashSet() {
}
public HashSet(int <warning descr="Parameter 'initialCapacity' is never used">initialCapacity</warning>, float <warning descr="Parameter 'loadFactor' is never used">loadFactor</warning>) {
}
public HashSet(int <warning descr="Parameter 'initialCapacity' is never used">initialCapacity</warning>) {
}
HashSet(int <warning descr="Parameter 'initialCapacity' is never used">initialCapacity</warning>, float <warning descr="Parameter 'loadFactor' is never used">loadFactor</warning>, boolean <warning descr="Parameter 'dummy' is never used">dummy</warning>) {
}
public boolean add(E e) {
return true;
}
}
abstract class AbstractSet<E> extends AbstractCollection<E> {
/**
* Sole constructor. (For invocation by subclass constructors, typically
* implicit.)
*/
protected AbstractSet() {
}
}
abstract class AbstractCollection<E> implements Collection<E> {
public boolean add(E e) {
return true;
}
public boolean addAll(Collection<? extends E> <warning descr="Parameter 'c' is never used">c</warning>) {
boolean modified = false;
return modified;
}
}
interface Collection<<warning descr="Type parameter 'E' is never used">E</warning>> {}

View File

@@ -0,0 +1,12 @@
public class Test<A,B> {
public static <P,Q> Test<P,Q> left(P p) { return null; }
public static <P,Q> Test<P,Q> right(Q q) { return null; }
public <C> C either(Function<A, C> leftFn, Function<B, C> rightFn){ return null; }
public Test<B,A> swap() {
return either(Test::<B,A>right, Test::<B,A>left);
}
}
interface Function<T, R> {
R fun(T t);
}

View File

@@ -0,0 +1,17 @@
public abstract class Tmp<T> {
private String concat(Tmp<String> tmp) {
return tmp.collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString();
}
abstract <R> R collect(Supplier<R> supplier,
BiConsumer<R, ? super T> accumulator,
BiConsumer<R, R> combiner);
interface Supplier<T> {
T get();
}
interface BiConsumer<T, U> {
void accept(T t, U u);
}
}

View File

@@ -0,0 +1,8 @@
public class Tmp
{
void foo(){}
void foo(Object... <warning descr="Parameter 'args' is never used">args</warning>){}
Runnable r = this::foo;
}

View File

@@ -0,0 +1,13 @@
interface Eff<A, B> {
B f(A a);
}
class Disfunction {
public static <A, B> Eff<A, B> vary(final Eff<? super A, ? extends B> f) {
return a -> f.f(a);
}
public static <C, A extends C, B, D extends B> Eff<Eff<C, D>, Eff<A, B>> vary() {
return Disfunction::<A, B>vary;
}
}

View File

@@ -0,0 +1,16 @@
class Test22 {
static <U> Iterable<U> map(Mapper<String, U> mapper) {
return null;
}
static void test() {
Iterable<Integer> map = <error>map(Test22 ::length)</error>;
}
public static <T> int length(String s) {
return 0;
}
}
interface Mapper<T, U> {
U map(T t);
}

View File

@@ -0,0 +1,22 @@
interface BiFun<T, U, R> {
R aly(T t, U u);
}
class Test {
public static <A, B> void foo() {
BiFun<? super A, ? super B, ? extends Pair<A, B>> p = Pair::new;
BiFun<? super A, ? super B, ? extends Pair<A, B>> p1 = Pair::create;
}
private static class Pair<A, B> {
private final A a;
private final B b;
protected Pair(A a, B b) {
this.a = a;
this.b = b;
}
static <M, N> Pair<M, N> create (M m, N n) {return null;}
}
}

View File

@@ -32,6 +32,6 @@ class ReturnTypeCompatibility {
call((String i)->{ return i;});
call(i->{ return i;});
call(i->"");
call((<error descr="Incompatible parameter types in lambda expression">int i</error>)->{ return i;});
call<error descr="'call(ReturnTypeCompatibility.I1<int>)' in 'ReturnTypeCompatibility' cannot be applied to '(<lambda expression>)'">((int i)->{ return i;})</error>;
}
}

View File

@@ -83,6 +83,22 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testAfterAbstractPipeline() throws Exception {
doTest();
}
public void testCapturedReturnTypes() throws Exception {
doTest();
}
public void testOverloadChooserOfReturnType() throws Exception {
doTest();
}
public void testIDEA98866() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/newLambda";
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
return new LocalInspectionTool[]{
new UnusedSymbolLocalInspection(),
};
}
public void testIDEA93586() throws Exception {
doTest();
}
public void testIDEA113573() throws Exception {
doTest();
}
public void testIDEA112922() throws Exception {
doTest();
}
public void testIDEA113504() throws Exception {
doTest();
}
public void testAfterAbstractPipeline2() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}
private void doTest(boolean warnings) {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef";
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
return new LocalInspectionTool[]{
new UnusedSymbolLocalInspection(),
};
}
public void testIDEA93587() throws Exception {
doTest(true);
}
public void testIDEA106522() throws Exception {
doTest();
}
public void testIDEA112574() throws Exception {
doTest();
}
public void testIDEA113558() throws Exception {
doTest(true);
}
public void testAfterDistinctOps() throws Exception {
doTest(true);
}
public void testWildcardReturns() throws Exception {
doTest(false);
}
public void _testInexactMethodReferencePrimitiveBound() throws Exception {
doTest(false);
}
public void testAfterCollectors1() throws Exception {
doTest(false);
}
public void testAfterCollectors2() throws Exception {
doTest(false);
}
private void doTest() {
doTest(false);
}
private void doTest(boolean warnings) {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
}

View File

@@ -28,6 +28,7 @@ import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
import com.intellij.testFramework.ExpectedHighlightingData;
import com.intellij.testFramework.FileTreeAccessFilter;
import com.intellij.testFramework.HighlightTestInfo;
@@ -84,7 +85,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
protected void doTestNewInference(@NonNls String filePath, boolean checkWarnings, boolean checkInfos) {
final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
//helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
try {
configureByFile(filePath);
doTestConfiguredFile(checkWarnings, checkInfos, filePath);