From e5860edabe31f3b6ceabd91f9cbcadf3d4d0315a Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sun, 1 Feb 2015 06:52:52 +0100 Subject: Fixed issues with val in inner classes, and re-enabled a test that caught it that we ignored earlier. --- src/utils/lombok/javac/TreeMirrorMaker.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/utils') diff --git a/src/utils/lombok/javac/TreeMirrorMaker.java b/src/utils/lombok/javac/TreeMirrorMaker.java index 621e4e00..093839d7 100644 --- a/src/utils/lombok/javac/TreeMirrorMaker.java +++ b/src/utils/lombok/javac/TreeMirrorMaker.java @@ -38,6 +38,7 @@ import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCNewClass; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.tree.TreeCopier; +import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.List; /** @@ -53,7 +54,7 @@ import com.sun.tools.javac.util.List; public class TreeMirrorMaker extends TreeCopier { private final IdentityHashMap originalToCopy = new IdentityHashMap(); - public TreeMirrorMaker(JavacTreeMaker maker) { + public TreeMirrorMaker(JavacTreeMaker maker, Context context) { super(maker.getUnderlyingTreeMaker()); } @@ -93,12 +94,14 @@ public class TreeMirrorMaker extends TreeCopier { return Collections.unmodifiableMap(originalToCopy); } - // Fix for NPE in HandleVal. See http://code.google.com/p/projectlombok/issues/detail?id=205 - // Maybe this should be done elsewhere... + // Monitor issue 205 and issue 694 when making changes here. @Override public JCTree visitVariable(VariableTree node, Void p) { + JCVariableDecl original = node instanceof JCVariableDecl ? (JCVariableDecl) node : null; JCVariableDecl copy = (JCVariableDecl) super.visitVariable(node, p); - copy.sym = ((JCVariableDecl) node).sym; - if (copy.sym != null) copy.type = ((JCVariableDecl) node).type; + if (original == null) return copy; + + copy.sym = original.sym; + if (copy.sym != null) copy.type = original.type; if (copy.type != null) { boolean wipeSymAndType = copy.type.isErroneous(); if (!wipeSymAndType) { -- cgit