src/share/classes/com/sun/tools/javac/comp/Flow.java

changeset 742
fdc67f5170e9
parent 735
f2048d9c666e
child 743
6a99b741a1b0
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Nov 12 12:32:43 2010 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Nov 12 12:33:52 2010 +0000
     1.3 @@ -1371,11 +1371,24 @@
     1.4          if (!tree.type.isErroneous()
     1.5              && lint.isEnabled(Lint.LintCategory.CAST)
     1.6              && types.isSameType(tree.expr.type, tree.clazz.type)
     1.7 -            && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))) {
     1.8 +            && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))
     1.9 +            && !is292targetTypeCast(tree)) {
    1.10              log.warning(Lint.LintCategory.CAST,
    1.11                      tree.pos(), "redundant.cast", tree.expr.type);
    1.12          }
    1.13      }
    1.14 +    //where
    1.15 +        private boolean is292targetTypeCast(JCTypeCast tree) {
    1.16 +            boolean is292targetTypeCast = false;
    1.17 +            if (tree.expr.getTag() == JCTree.APPLY) {
    1.18 +                JCMethodInvocation apply = (JCMethodInvocation)tree.expr;
    1.19 +                Symbol sym = TreeInfo.symbol(apply.meth);
    1.20 +                is292targetTypeCast = sym != null &&
    1.21 +                    sym.kind == MTH &&
    1.22 +                    (sym.flags() & POLYMORPHIC_SIGNATURE) != 0;
    1.23 +            }
    1.24 +            return is292targetTypeCast;
    1.25 +        }
    1.26  
    1.27      public void visitTopLevel(JCCompilationUnit tree) {
    1.28          // Do nothing for TopLevel since each class is visited individually

mercurial