mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
TypeConstraint: fix deep hierarchy union (IDEA-CR-31134)
This commit is contained in:
+2
-1
@@ -197,7 +197,8 @@ public final class TypeConstraint {
|
||||
|
||||
private static Set<DfaPsiType> withSuper(Set<DfaPsiType> instanceofValues) {
|
||||
return StreamEx.of(instanceofValues)
|
||||
.flatMap(type -> StreamEx.of(type.getPsiType().getSuperTypes()).map(type.getFactory()::createDfaType).append(type))
|
||||
.flatMap(type -> StreamEx.ofTree(type.getPsiType(), t -> StreamEx.of(t.getSuperTypes()))
|
||||
.map(type.getFactory()::createDfaType))
|
||||
.toSet();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.math.BigInteger;
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
interface Base {
|
||||
void baseMethod();
|
||||
}
|
||||
|
||||
interface A1 extends Base {}
|
||||
interface A2 extends Base {}
|
||||
interface B1 extends A1 {}
|
||||
interface B2 extends A2 {}
|
||||
interface C1 extends B1 {}
|
||||
|
||||
long test(Object obj) {
|
||||
if (obj instanceof C1 || obj instanceof A2) {
|
||||
obj.baseMe<caret>
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import java.math.BigInteger;
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
interface Base {
|
||||
void baseMethod();
|
||||
}
|
||||
|
||||
interface A1 extends Base {}
|
||||
interface A2 extends Base {}
|
||||
interface B1 extends A1 {}
|
||||
interface B2 extends A2 {}
|
||||
interface C1 extends B1 {}
|
||||
|
||||
long test(Object obj) {
|
||||
if (obj instanceof C1 || obj instanceof A2) {
|
||||
((Base) obj).baseMethod();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+1
@@ -63,6 +63,7 @@ class NormalCompletionDfaTest extends NormalCompletionTestCase {
|
||||
void testInstanceOfAfterFunction() { doTest() }
|
||||
void testInstanceOfDisjunction() { doTest() }
|
||||
void testInstanceOfDisjunction2() { doTest() }
|
||||
void testInstanceOfDisjunctionDeep() { doTest() }
|
||||
void testComplexInstanceOfDfa() {
|
||||
configureByTestName()
|
||||
myFixture.assertPreferredCompletionItems 0, 'methodFromX', 'methodFromX2', 'methodFromY', 'methodFromY2'
|
||||
|
||||
Reference in New Issue
Block a user