aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-07-01 21:21:00 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2015-01-31 04:40:00 +0100
commit6a91c013ca2b20cc378515b83e3584f1dad958c0 (patch)
treea8aec0106d8ed34fe54f62aa9b14d5135cf21b78 /src/core/lombok
parente5705f94cd3778a2e0d25060f1e013d0c33bfb90 (diff)
downloadlombok-6a91c013ca2b20cc378515b83e3584f1dad958c0.tar.gz
lombok-6a91c013ca2b20cc378515b83e3584f1dad958c0.tar.bz2
lombok-6a91c013ca2b20cc378515b83e3584f1dad958c0.zip
[i694] When we resolve anything with inner classes, supertype references in those inner classes
that also have val will break, depending on compile order. This should fix it.
Diffstat (limited to 'src/core/lombok')
-rw-r--r--src/core/lombok/javac/JavacResolution.java2
-rw-r--r--src/core/lombok/javac/apt/Processor.java15
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java11
3 files changed, 25 insertions, 3 deletions
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index 23d7d482..294d4fea 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -241,7 +241,7 @@ public class JavacResolution {
Type type0 = type;
while (type0 instanceof ArrayType) {
dims++;
- type0 = ((ArrayType)type0).elemtype;
+ type0 = ((ArrayType) type0).elemtype;
}
JCExpression result = typeToJCTree0(type0, ast, allowCompound, allowVoid);
diff --git a/src/core/lombok/javac/apt/Processor.java b/src/core/lombok/javac/apt/Processor.java
index ce4d75ff..783cf6b4 100644
--- a/src/core/lombok/javac/apt/Processor.java
+++ b/src/core/lombok/javac/apt/Processor.java
@@ -28,13 +28,14 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashSet;
-import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
+import java.util.TreeMap;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
@@ -217,7 +218,17 @@ public class Processor extends AbstractProcessor {
}
}
- private final IdentityHashMap<JCCompilationUnit, Long> roots = new IdentityHashMap<JCCompilationUnit, Long>();
+ // DEBUG - We just blithely assume that there's always a sourcefile.getName() component, and that the performance impact of this is not relevant.
+ // - ... but mostly the 'just blithely assume there's a sourcefile' part means we shouldn't just roll this out.
+ private final Map<JCCompilationUnit,Long> roots = new TreeMap<JCCompilationUnit, Long>(new Comparator<JCCompilationUnit>() {
+ @Override public int compare(JCCompilationUnit o1, JCCompilationUnit o2) {
+ if (o1 == o2) return 0;
+
+ int c = o1.sourcefile.getName().compareTo(o2.sourcefile.getName());
+ if (c != 0) return c;
+ return System.identityHashCode(o1) < System.identityHashCode(o2) ? -1 : +1;
+ }
+ });
private long[] priorityLevels;
private Set<Long> priorityLevelsRequiringResolutionReset;
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 0230e1b0..ea0e38f5 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -35,6 +35,7 @@ import lombok.javac.ResolutionResetNeeded;
import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -110,6 +111,16 @@ public class HandleVal extends JavacASTAdapter {
}
} else {
type = local.init.type;
+ if (type.isErroneous()) {
+ try {
+ JavacResolution resolver = new JavacResolution(localNode.getContext());
+ local.type = Symtab.instance(localNode.getContext()).unknownType;
+ type = ((JCExpression) resolver.resolveMethodMember(localNode).get(local.init)).type;
+ } catch (RuntimeException e) {
+ System.err.println("Exception while resolving: " + localNode);
+ throw e;
+ }
+ }
}
} else {
if (rhsOfEnhancedForLoop.type == null) {