mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
IDEA-177895 Completion items with type casts derived from control flow are not suggested for 'this'
This commit is contained in:
+7
-2
@@ -398,8 +398,13 @@ public class GuessManagerImpl extends GuessManager {
|
||||
private Map<PsiExpression, PsiType> myResult;
|
||||
private final PsiElement myForPlace;
|
||||
|
||||
private ExpressionTypeInstructionVisitor(PsiElement forPlace) {
|
||||
myForPlace = forPlace;
|
||||
private ExpressionTypeInstructionVisitor(@NotNull PsiElement forPlace) {
|
||||
PsiElement parent = PsiUtil.skipParenthesizedExprUp(forPlace.getParent());
|
||||
if (forPlace instanceof PsiThisExpression && parent instanceof PsiReferenceExpression) {
|
||||
myForPlace = parent.getParent() instanceof PsiMethodCallExpression ? parent.getParent() : parent;
|
||||
} else {
|
||||
myForPlace = forPlace;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<PsiExpression, PsiType> getResult() {
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
public abstract class Super {
|
||||
|
||||
void foo() {
|
||||
if (this instanceof Sub) {
|
||||
this.subme<caret>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Sub extends Zzza {
|
||||
void subMethod() {}
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
public abstract class Super {
|
||||
|
||||
void foo() {
|
||||
if (this instanceof Sub) {
|
||||
((Sub) this).subMethod();<caret>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Sub extends Zzza {
|
||||
void subMethod() {}
|
||||
|
||||
}
|
||||
+3
-1
@@ -33,7 +33,9 @@ class NormalCompletionDfaTest extends LightFixtureCompletionTestCase {
|
||||
void _testCastIncompleteInstanceofedQualifier() { doTest() }
|
||||
|
||||
void testCastTooComplexInstanceofedQualifier() { doAntiTest() }
|
||||
|
||||
|
||||
void testCastInstanceofedThisQualifier() { doTest() }
|
||||
|
||||
void testDontCastInstanceofedQualifier() { doTest() }
|
||||
void testDontCastPartiallyInstanceofedQualifier() { doAntiTest() }
|
||||
void testQualifierCastingWithUnknownAssignments() { doTest() }
|
||||
|
||||
Reference in New Issue
Block a user