bugfix: our new trick to try and disable target typing by making the LHS of a 'val' statement be of an unknown type instead of j.l.Object works for Javac8, but breaks Javac6! We now detect this and pick the right strategy based on whether or not the compiler supports target typing.

This commit is contained in:
Reinier Zwitserloot committed 2014-05-08 00:39:59 +02:00
1 parent 65d89f077e
commit 7f85149f39
2 files changed
+10 -13

No files matched your search

+5 -12
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2013 The Project Lombok Authors.
* Copyright (C) 2011-2014 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -94,17 +94,6 @@ public class JavacResolution {
@Override public void visitClassDef(JCClassDecl tree) {
if (copyAt != null) return;
// The commented out stuff requires reflection tricks to avoid leaving lint unset which causes NPEs during attrib. So, we use the other one, much less code.
// env = enter.classEnv((JCClassDecl) tree, env);
// try {
// Field f = env.info.getClass().getDeclaredField("lint");
// f.setAccessible(true);
// Constructor<?> c = Lint.class.getDeclaredConstructor(Lint.class);
// c.setAccessible(true);
// f.set(env.info, c.newInstance(lint));
// } catch (Exception e) {
// throw Lombok.sneakyThrow(e);
// }
env = enter.getClassEnv(tree.sym);
}
@@ -358,4 +347,8 @@ public class JavacResolution {
throw new TypeNotConvertibleException("Nulltype");
}
}
public static boolean platformHasTargetTyping() {
return Javac.getJavaCompilerVersion() >= 8;
}
}
@@ -91,7 +91,11 @@ public class HandleVal extends JavacASTAdapter {
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
}
local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__"));
if (JavacResolution.platformHasTargetTyping()) {
local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__"));
} else {
local.vartype = JavacResolution.createJavaLangObject(localNode.getAst());
}
Type type;
try {