mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
inference: ensure to convert disjunction type to lub (IDEA-150364)
This commit is contained in:
@@ -50,7 +50,7 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
|
||||
return assignmentCompatible;
|
||||
}
|
||||
|
||||
final PsiType exprType = myExpression.getType();
|
||||
PsiType exprType = myExpression.getType();
|
||||
|
||||
if (exprType instanceof PsiLambdaParameterType) {
|
||||
return false;
|
||||
@@ -67,6 +67,10 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
|
||||
}
|
||||
|
||||
if (exprType != null && exprType != PsiType.NULL) {
|
||||
if (exprType instanceof PsiDisjunctionType) {
|
||||
exprType = ((PsiDisjunctionType)exprType).getLeastUpperBound();
|
||||
}
|
||||
|
||||
constraints.add(new TypeCompatibilityConstraint(myT, exprType));
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
class Test {
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
}
|
||||
catch (Exception | Error e) {
|
||||
<error descr="Unhandled exception: java.lang.Throwable">throw identity(identity(e));</error>
|
||||
}
|
||||
|
||||
try {
|
||||
}
|
||||
catch (Exception | Error e) {
|
||||
<error descr="Unhandled exception: java.lang.Throwable">throw identity(e);</error>
|
||||
}
|
||||
|
||||
try {
|
||||
}
|
||||
catch (Exception | Error e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T identity(T throwable) {
|
||||
return throwable;
|
||||
}
|
||||
}
|
||||
@@ -359,6 +359,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDisjunctionTypes() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user