mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
[java-highlighting] GenericsUtil.getLeastUpperBound: support PsiDisjunctionType
Fixes IDEA-320698 False positive error highlighting of an expression with an union type in a throw statement GitOrigin-RevId: 7120053a75edbcb8717657b9791d1a310a581c32
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b47e2068ba
commit
379a59d56b
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -46,6 +46,13 @@ public final class GenericsUtil {
|
||||
return getLeastUpperBound(type1, ((PsiCapturedWildcardType)type2).getUpperBound(), compared, manager);
|
||||
}
|
||||
|
||||
if (type1 instanceof PsiDisjunctionType) {
|
||||
return getLeastUpperBound(((PsiDisjunctionType)type1).getLeastUpperBound(), type2, compared, manager);
|
||||
}
|
||||
if (type2 instanceof PsiDisjunctionType) {
|
||||
return getLeastUpperBound(type1, ((PsiDisjunctionType)type2).getLeastUpperBound(), compared, manager);
|
||||
}
|
||||
|
||||
if (type1 instanceof PsiWildcardType) {
|
||||
return getLeastUpperBound(((PsiWildcardType)type1).getExtendsBound(), type2, compared, manager);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class SomeClass {
|
||||
static class Ex1 extends Exception {}
|
||||
static class Ex2 extends Exception {}
|
||||
|
||||
native void run() throws Ex1, Ex2;
|
||||
|
||||
void test() throws Exception {
|
||||
try {
|
||||
run();
|
||||
} catch (Ex1 | Ex2 e) {
|
||||
throw e.getCause() != null ? new RuntimeException() : e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
@@ -89,6 +89,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
public void testNumericLiterals() { doTest(false, false); }
|
||||
public void testMultiCatch() { doTest(false, false); }
|
||||
public void testMultiCatchRethrowConditional() { doTest(false, false); }
|
||||
public void testTryWithResources() { doTest(false, false); }
|
||||
public void testTryWithResourcesWarn() { doTest(true, false, new DefUseInspection()); }
|
||||
public void testSafeVarargsApplicability() { doTest(true, false); }
|
||||
|
||||
Reference in New Issue
Block a user