mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-123870 Completion does not suggest expected methods after instanceof
This commit is contained in:
+6
-2
@@ -26,6 +26,7 @@ import com.intellij.psi.PsiType;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -110,7 +111,10 @@ public class ExpressionTypeMemoryState extends DfaMemoryStateImpl {
|
||||
return super.toString() + " states=[" + new HashMap<PsiExpression, PsiType>(myStates) + "]";
|
||||
}
|
||||
|
||||
public void setExpressionType(PsiExpression expression, PsiType type) {
|
||||
myStates.put(expression, type);
|
||||
public void setExpressionType(PsiExpression expression, @NotNull PsiType type) {
|
||||
PsiType prev = myStates.get(expression);
|
||||
if (prev == null || !type.isAssignableFrom(prev)) {
|
||||
myStates.put(expression, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
public class Class2 {
|
||||
void test(Object o) {
|
||||
if (o instanceof B && ((A)o).a() && o.<caret>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface A {
|
||||
boolean a();
|
||||
}
|
||||
|
||||
interface B extends A {
|
||||
boolean b();
|
||||
}
|
||||
+6
-1
@@ -40,7 +40,12 @@ class NormalCompletionDfaTest extends LightFixtureCompletionTestCase {
|
||||
void testCastQualifierForPrivateFieldReference() { doTest(); }
|
||||
void testOrAssignmentDfa() { doTest(); }
|
||||
void testFieldWithCastingCaret() { doTest(); }
|
||||
|
||||
|
||||
void testCastTwice() {
|
||||
configureByTestName()
|
||||
myFixture.assertPreferredCompletionItems 0, 'b', 'a'
|
||||
}
|
||||
|
||||
void testPublicMethodExtendsProtected() {
|
||||
myFixture.addClass '''
|
||||
package foo;
|
||||
|
||||
Reference in New Issue
Block a user