--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Wed Nov 29 14:45:41 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Wed Nov 29 14:41:09 2017 +0100
@@ -63,6 +63,7 @@
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.Position;
import java.util.EnumSet;
import java.util.HashMap;
@@ -305,7 +306,7 @@
JCMethodDecl md = (JCMethodDecl)decls(oldTree.def).head;
List<JCVariableDecl> params = md.params;
JCBlock body = md.body;
- JCLambda newTree = make.Lambda(params, body);
+ JCLambda newTree = make.at(oldTree).Lambda(params, body);
return List.of(newTree);
}
@@ -418,7 +419,7 @@
List<JCEnhancedForLoop> rewrite(JCEnhancedForLoop oldTree) {
JCEnhancedForLoop newTree = copier.copy(oldTree);
newTree.var = rewriteVarType(oldTree.var);
- newTree.body = make.Block(0, List.nil());
+ newTree.body = make.at(oldTree.body).Block(0, List.nil());
return List.of(newTree);
}
@Override
@@ -551,7 +552,8 @@
JCStatement treeToAnalyze = (JCStatement)rewriting.originalTree;
if (rewriting.env.info.scope.owner.kind == Kind.TYP) {
//add a block to hoist potential dangling variable declarations
- treeToAnalyze = make.Block(Flags.SYNTHETIC, List.of((JCStatement)rewriting.originalTree));
+ treeToAnalyze = make.at(Position.NOPOS)
+ .Block(Flags.SYNTHETIC, List.of((JCStatement)rewriting.originalTree));
}
//TODO: to further refine the analysis, try all rewriting combinations