boolean (@NotNull PsiExpression anchor) { if (anchor instanceof PsiInstanceOfExpression) { PsiType type = ((PsiInstanceOfExpression)anchor).getOperand().getType(); if (type == null || !TypeConstraints.instanceOf(type).isResolved()) return true; // 5.20.2 Removed restriction on pattern instanceof for unconditional patterns (JEP 427) if (HighlightingFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(anchor)) return false; PsiPattern pattern = ((PsiInstanceOfExpression)anchor).getPattern(); if (pattern instanceof PsiTypeTestPattern && ((PsiTypeTestPattern)pattern).getPatternVariable() != null) { PsiTypeElement checkType = ((PsiTypeTestPattern)pattern).getCheckType(); // Reported as compilation error return checkType != null && checkType.getType().isAssignableFrom(type); } } return false; }