inference: don't process lambda return expressions for void return type

those lambda return expressions can't influence containing call inference according to lambda constraint; which means that no additional inference variables could be propagated during inference process hence exception constraints could operate with proper types which are in fact type parameters - which would lead to unhandled exceptions on the top level (IDEA-187930)
This commit is contained in:
Anna.Kozlova
2018-03-08 11:53:52 +01:00
parent 39452636c5
commit 877b2424ce
3 changed files with 58 additions and 1 deletions
@@ -0,0 +1,56 @@
import java.io.IOException;
class Test {
interface ThrowableRunnable<T extends Throwable> {
void run() throws T;
}
interface ThrowableComputable<R, E extends Throwable> {
R compute() throws E;
}
private <D extends Throwable> void doTest(ThrowableRunnable<D> action) { }
public void testNoNotificationForWorkspace() {
doTest(() -> computeAndWait(() -> foo()));
}
private String foo() throws IOException {
return null;
}
public static <R, E extends Throwable> R computeAndWait(ThrowableComputable<R, E> action) throws E {
return null;
}
}
class TestWithImplicitLambda {
interface ThrowableRunnable<T extends Throwable> {
void run(int k) throws T;
}
interface ThrowableComputable<R, E extends Throwable> {
R compute() throws E;
}
private <D extends Throwable> void doTest(ThrowableRunnable<D> action) { }
public void testNoNotificationForWorkspace() {
doTest((k) -> computeAndWait(() -> foo()));
}
private String foo() throws IOException {
return null;
}
public static <R, E extends Throwable> R computeAndWait(ThrowableComputable<R, E> action) throws E {
return null;
}
}