mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ControlFlowAnalyzer#visitInstanceOfExpression: exclude check on unresolved type
Otherwise red code `x instanceof Unresolved` produces also "always false" warning which is quite useless.
This commit is contained in:
+10
-6
@@ -1606,17 +1606,21 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
@Override public void visitInstanceOfExpression(PsiInstanceOfExpression expression) {
|
||||
startElement(expression);
|
||||
PsiExpression operand = expression.getOperand();
|
||||
operand.accept(this);
|
||||
PsiTypeElement checkType = expression.getCheckType();
|
||||
if (checkType != null) {
|
||||
operand.accept(this);
|
||||
PsiType type = checkType.getType();
|
||||
if (type instanceof PsiClassType) {
|
||||
type = ((PsiClassType)type).rawType();
|
||||
}
|
||||
PsiType type = checkType != null ? checkType.getType() : null;
|
||||
if (type instanceof PsiClassType) {
|
||||
type = ((PsiClassType)type).rawType();
|
||||
}
|
||||
boolean validInstanceOf = type != null &&
|
||||
(!(type.getDeepComponentType() instanceof PsiClassType) ||
|
||||
PsiUtil.resolveClassInType(type.getDeepComponentType()) != null);
|
||||
if (validInstanceOf) {
|
||||
addInstruction(new PushInstruction(myFactory.createTypeValue(type, Nullability.NOT_NULL), null));
|
||||
addInstruction(new InstanceofInstruction(expression, operand, type));
|
||||
}
|
||||
else {
|
||||
addInstruction(new PopInstruction());
|
||||
pushUnknown();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user