--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Mon Mar 26 17:33:58 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Wed Mar 28 14:08:26 2018 +0100
@@ -358,6 +358,10 @@
super(AnalyzerMode.LOCAL, tag);
}
+ boolean isImplicitlyTyped(JCVariableDecl decl) {
+ return decl.vartype.pos == Position.NOPOS;
+ }
+
/**
* Map a variable tree into a new declaration using implicit type.
*/
@@ -390,7 +394,7 @@
boolean match(JCVariableDecl tree){
return tree.sym.owner.kind == Kind.MTH &&
- tree.init != null && !tree.isImplicitlyTyped() &&
+ tree.init != null && !isImplicitlyTyped(tree) &&
attr.canInferLocalVarType(tree) == null;
}
@Override
@@ -414,7 +418,7 @@
@Override
boolean match(JCEnhancedForLoop tree){
- return !tree.var.isImplicitlyTyped();
+ return !isImplicitlyTyped(tree.var);
}
@Override
List<JCEnhancedForLoop> rewrite(JCEnhancedForLoop oldTree) {