mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
exception inference: don't check non-applicable methods (IDEA-178762)
This commit is contained in:
@@ -487,13 +487,15 @@ public class ExceptionUtil {
|
||||
processor.getResults(), info -> {
|
||||
PsiElement element1 = info.getElement();
|
||||
if (info instanceof MethodCandidateInfo &&
|
||||
element1 != method && //don't check self
|
||||
MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element1) &&
|
||||
!MethodSignatureUtil.isSuperMethod((PsiMethod)element1, method)) {
|
||||
!MethodSignatureUtil.isSuperMethod((PsiMethod)element1, method) &&
|
||||
!(((MethodCandidateInfo)info).isToInferApplicability() && !((MethodCandidateInfo)info).isApplicable())) {
|
||||
return Pair.create((PsiMethod)element1, ((MethodCandidateInfo)info).getSubstitutor(false));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if (candidates.size() > 1) {
|
||||
if (!candidates.isEmpty()) {
|
||||
GlobalSearchScope scope = methodCall.getResolveScope();
|
||||
final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions, scope);
|
||||
for (Pair<PsiMethod, PsiSubstitutor> pair : candidates) {
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@FunctionalInterface
|
||||
interface ThrowableRunnable<E extends Exception> {
|
||||
|
||||
void get() throws E;
|
||||
|
||||
static <E extends Exception> void m(ThrowableRunnable<E> supplier, Object... params) throws E {}
|
||||
|
||||
|
||||
default void getContent() {
|
||||
try {
|
||||
m(() -> { throw new IOException(); });
|
||||
} catch (IOException e) { }
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -162,6 +162,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testLambdaWithFormalTypeParameters() { doTest(); }
|
||||
public void testIDEA174924() { doTest(); }
|
||||
public void testVoidValueCompatibilityWithBreakInSwitch() { doTest(); }
|
||||
public void testExceptionInferenceForVarargMethods() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
|
||||
Reference in New Issue
Block a user