lambda.isValueCompatible should not cache inference results for calls inside lambda body as they may depend on incomplete top level inference where LambdaExpressionCompatibilityConstraint is reduced (IDEA-156311)

This commit is contained in:
Anna.Kozlova
2016-05-20 18:03:15 +02:00
parent 4332c90534
commit ce58f62d19
4 changed files with 151 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
import java.util.function.Supplier;
import java.io.IOException;
interface A {
}
interface B extends A {
}
interface D<TT extends Exception> {
<T extends A, E extends TT> T foo() throws E;
}
class E {
void bar(D<RuntimeException> d) {
foobar(supplier(() -> {
try {
return d.foo();
} catch (RuntimeException e) {
throw e;
}
}));
foobar(supplier(() -> {
return d.foo();
}));
foobar(supplier(() -> d.foo()));
foobar(supplier(d::foo));
foobar(supplier(() -> {
throw new RuntimeException();
}));
}
<T> Supplier<T> supplier(Supplier<T> s) {
return s;
}
void foobar(Supplier<B> s) {
}
}
class Test {
interface A {
}
interface B extends A {
}
interface D {
<T extends A> T foo() throws IOException;
}
class E {
void bar(D d) {
foobar(supplier(() -> {
try {
return d.foo();
} catch (IOException e) {
throw new RuntimeException();
}
}));
}
<T> Supplier<T> supplier(Supplier<T> s) {
return s;
}
void foobar(Supplier<B> s) {
}
}
}
class TestNoTypeParameterBounds {
interface A {
}
interface B extends A {
}
interface D {
<T extends A, E extends Throwable> T foo() throws E;
}
class E {
void bar(D d) {
foobar(supplier(() -> {
try {
return d.foo();
} catch (RuntimeException e) {
throw e;
}
}));
foobar(supplier(() -> {
return d.foo();
}));
foobar(supplier(() -> d.foo()));
foobar(supplier(d::foo));
foobar(supplier(() -> {
throw new RuntimeException();
}));
}
<T> Supplier<T> supplier(Supplier<T> s) {
return s;
}
void foobar(Supplier<B> s) {
}
}
}