lambda: check assignment for proper types (IDEA-137564)

This commit is contained in:
Anna Kozlova
2015-03-12 18:36:30 +01:00
parent 9318783a78
commit 027943681f
3 changed files with 21 additions and 2 deletions

View File

@@ -116,7 +116,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
thrownTypes.addAll(ContainerUtil.filter(exceptions, new Condition<PsiClassType>() {
@Override
public boolean value(PsiClassType type) {
return session.isProperType(type) && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_EXCEPTION);
return !ExceptionUtil.isUncheckedException(type);
}
}));
}
@@ -154,7 +154,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
}
} else {
final ArrayList<PsiType> expectedProperTypes = new ArrayList<PsiType>(expectedThrownTypes);
expectedProperTypes.retainAll(expectedNonProperThrownTypes);
expectedProperTypes.removeAll(expectedNonProperThrownTypes);
for (PsiType thrownType : thrownTypes) {
if (!isAddressed(expectedProperTypes, thrownType)) {
for (PsiType expectedNonProperThrownType : expectedNonProperThrownTypes) {

View File

@@ -0,0 +1,15 @@
abstract class Main {
public interface LifetimeFunction<ELF extends Throwable> {
int execute() throws ELF;
}
public final <E extends Throwable> void foo(final LifetimeFunction<E> action) throws E {
runSync(() -> {
action.execute();
return 42;
});
}
abstract < E1 extends Throwable> void runSync(LifetimeFunction<E1> action) throws E1;
}

View File

@@ -145,6 +145,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testCheckedExceptionsConstraintsSubstitutions2() throws Exception {
doTest();
}
public void testCheckedExceptionsConstraintsSubstitutionsDeepInBody() throws Exception {
doTest();
}