@Override
      public void visitTypeCastExpression(@NotNull PsiTypeCastExpression cast) {
        PsiTypeElement castTypeElement = cast.getCastType();
        if (castTypeElement == null || castTypeElement.getAnnotations().length > 0) return;
        PsiType castType = GenericsUtil.getVariableTypeByExpressionType(cast.getType());
        if (!(castType instanceof PsiClassType) || ((PsiClassType)castType).isRaw()) return;
        PsiReferenceExpression ref = tryCast(PsiUtil.skipParenthesizedExprDown(cast.getOperand()), PsiReferenceExpression.class);
        if (ref == null) return;
        PsiVariable variable = tryCast(ref.resolve(), PsiVariable.class);
        if (!PsiUtil.isJvmLocalVariable(variable)) return;
        if (variable instanceof PsiParameter parameter) {
          PsiForeachStatement forEach = tryCast(parameter.getDeclarationScope(), PsiForeachStatement.class);
          if (forEach == null) return;
          PsiExpression collection = forEach.getIteratedValue();
          if (collection == null) return;
          PsiType elementType = JavaGenericsUtil.getCollectionItemType(collection);
          if (elementType == null || !castType.isAssignableFrom(elementType)) return;
          PsiType elementVarType = GenericsUtil.getVariableTypeByExpressionType(elementType);
          if (elementVarType instanceof PsiClassType elementClassType && elementClassType.isRaw()) return;
        } else {
          PsiExpression variableInitializer = variable.getInitializer();
          if (variableInitializer != null) {
            PsiType initializerType = GenericsUtil.getVariableTypeByExpressionType(variableInitializer.getType());
            if (initializerType == null || !castType.isAssignableFrom(initializerType)) return;
          }
        }
        if (!InstanceOfUtils.isSafeToNarrowType(variable, cast, castType)) return;
        String message = JavaBundle
          .message("inspection.cast.can.be.removed.narrowing.variable.type.message", variable.getName(), castType.getPresentableText());
        holder.registerProblem(castTypeElement, message, new CastCanBeRemovedNarrowingVariableTypeFix(variable, castType, isOnTheFly));
      }
@Override
      public void visitTypeCastExpression(@NotNull PsiTypeCastExpression cast)