public static boolean isCastNeeded(@NotNull GrExpression qualifier, @NotNull final PsiMember member, ExpressionContext context) {
    PsiType declared = getDeclaredType(qualifier, context);
    if (declared == null) return false;

    final CheckProcessElement checker = new CheckProcessElement(member);

    if (ResolveUtil.resolvesToClass(qualifier)) {
      PsiType type = ResolveUtil.unwrapClassType(declared);
      if (type != null) {
        ResolveUtil.processAllDeclarations(type, checker, false, qualifier);
        if (checker.isFound()) {
          return false;
        }
      }
    }

    ResolveUtil.processAllDeclarations(declared, checker, false, qualifier);
    return !checker.isFound();
  }
public static boolean isCastNeeded(@NotNull GrExpression qualifier, @NotNull final PsiMember member, ExpressionContext context)