@Override
  public void visitInstanceOfExpression(@NotNull PsiInstanceOfExpression expression) {
    final PsiInstanceOfExpression other = getExpression(PsiInstanceOfExpression.class, expression);
    if (other == null) return;
    if (!myMatchingVisitor.setResult(myMatchingVisitor.match(expression.getOperand(), other.getOperand()))) return;
    PsiTypeElement expressionType = InstanceOfUtils.findCheckTypeElement(expression);
    PsiTypeElement otherType = InstanceOfUtils.findCheckTypeElement(other);
    if (!myMatchingVisitor.setResult(myMatchingVisitor.match(expressionType, otherType))) return;
    final PsiPattern pattern = expression.getPattern();
    PsiPattern otherPattern = other.getPattern();
    if (pattern instanceof PsiTypeTestPattern typeTestPattern) {
      if (otherPattern instanceof PsiTypeTestPattern otherVariable) {
        myMatchingVisitor.setResult(
          myMatchingVisitor.matchOptionally(typeTestPattern.getPatternVariable(), otherVariable.getPatternVariable()));
      }
      else {
        myMatchingVisitor.setResult(myMatchingVisitor.allowsAbsenceOfMatch(typeTestPattern.getPatternVariable()));
      }
    }
    else {
      myMatchingVisitor.setResult(myMatchingVisitor.match(pattern, otherPattern));
    }
  }
@Override
  public void visitInstanceOfExpression(@NotNull PsiInstanceOfExpression expression)