From 844414768c49677f344704328905f1ab3f7b67a8 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 8 Nov 2010 23:27:31 +0100 Subject: Ran into a one-off, non-repeatable problem involving arguments not binding correctly. Just in case its our fault, added some extra code to not even attempt any 'val' shenanigans in method arguments (which are LocalDeclaration subclasses). --- src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 3 ++- src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index b5132ca4..399ea357 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -282,7 +282,8 @@ public class EclipsePatcher extends Agent { sm.addScript(ScriptBuilder.replaceMethodCall() .target(new MethodTarget(LOCALDECLARATION_SIG, "resolve", "void", BLOCKSCOPE_SIG)) .methodToReplace(new Hook(EXPRESSION_SIG, "resolveType", TYPEBINDING_SIG, BLOCKSCOPE_SIG)) - .replacementMethod(new Hook("lombok.eclipse.agent.PatchFixes", "skipResolveInitializerIfAlreadyCalled", TYPEBINDING_SIG, EXPRESSION_SIG, BLOCKSCOPE_SIG)) + .requestExtra(StackRequest.THIS) + .replacementMethod(new Hook("lombok.eclipse.agent.PatchFixes", "skipResolveInitializerIfAlreadyCalled2", TYPEBINDING_SIG, EXPRESSION_SIG, BLOCKSCOPE_SIG, LOCALDECLARATION_SIG)) .build()); sm.addScript(ScriptBuilder.exitEarly() diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index 32335ecc..e2a52929 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -268,6 +268,7 @@ public class PatchFixes { } public static boolean handleValForLocalDeclaration(LocalDeclaration local, BlockScope scope) { + if (local == null || !LocalDeclaration.class.equals(local.getClass())) return false; boolean decomponent = false; if (local.type instanceof SingleTypeReference) { @@ -313,4 +314,9 @@ public class PatchFixes { if (expr.resolvedType != null) return expr.resolvedType; return expr.resolveType(scope); } + + public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) { + if (decl != null && LocalDeclaration.class.equals(decl.getClass()) && expr.resolvedType != null) return expr.resolvedType; + return expr.resolveType(scope); + } } -- cgit