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

changeset 742
fdc67f5170e9
parent 735
f2048d9c666e
child 743
6a99b741a1b0
equal deleted inserted replaced
741:58ceeff50af8 742:fdc67f5170e9
1369 public void visitTypeCast(JCTypeCast tree) { 1369 public void visitTypeCast(JCTypeCast tree) {
1370 super.visitTypeCast(tree); 1370 super.visitTypeCast(tree);
1371 if (!tree.type.isErroneous() 1371 if (!tree.type.isErroneous()
1372 && lint.isEnabled(Lint.LintCategory.CAST) 1372 && lint.isEnabled(Lint.LintCategory.CAST)
1373 && types.isSameType(tree.expr.type, tree.clazz.type) 1373 && types.isSameType(tree.expr.type, tree.clazz.type)
1374 && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))) { 1374 && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))
1375 && !is292targetTypeCast(tree)) {
1375 log.warning(Lint.LintCategory.CAST, 1376 log.warning(Lint.LintCategory.CAST,
1376 tree.pos(), "redundant.cast", tree.expr.type); 1377 tree.pos(), "redundant.cast", tree.expr.type);
1377 } 1378 }
1378 } 1379 }
1380 //where
1381 private boolean is292targetTypeCast(JCTypeCast tree) {
1382 boolean is292targetTypeCast = false;
1383 if (tree.expr.getTag() == JCTree.APPLY) {
1384 JCMethodInvocation apply = (JCMethodInvocation)tree.expr;
1385 Symbol sym = TreeInfo.symbol(apply.meth);
1386 is292targetTypeCast = sym != null &&
1387 sym.kind == MTH &&
1388 (sym.flags() & POLYMORPHIC_SIGNATURE) != 0;
1389 }
1390 return is292targetTypeCast;
1391 }
1379 1392
1380 public void visitTopLevel(JCCompilationUnit tree) { 1393 public void visitTopLevel(JCCompilationUnit tree) {
1381 // Do nothing for TopLevel since each class is visited individually 1394 // Do nothing for TopLevel since each class is visited individually
1382 } 1395 }
1383 1396

mercurial