mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
lambda: check assignment for proper types (IDEA-137564)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -145,6 +145,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCheckedExceptionsConstraintsSubstitutions2() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCheckedExceptionsConstraintsSubstitutionsDeepInBody() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user