Skip to content

Commit f129fa8

Browse files
authoredFeb 27, 2020
Merge pull request #2376 from Rawi01/extensionMethod
Set missing argumentTypes for eclipse extension methods
2 parents fc04b74 + cf1cffa commit f129fa8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
 

‎AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Peter Grant <petercgrant@users.noreply.github.com>
2828
Philipp Eichhorn <peichhor@web.de>
2929
Philippe Charles <philippe.charles@nbb.be>
3030
Rabea Gransberger <rgra@users.noreply.github.com>
31+
Raul Wißfeld <Rawi01@users.noreply.github.com>
3132
Reinier Zwitserloot <reinier@zwitserloot.com>
3233
Robbert Jan Grootjans <grootjans@gmail.com>
3334
Robert Wertman <robert.wertman@gmail.com>

‎src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java

+23
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static lombok.eclipse.handlers.EclipseHandlerUtil.createAnnotation;
2525

2626
import java.lang.ref.WeakReference;
27+
import java.lang.reflect.Field;
2728
import java.lang.reflect.InvocationTargetException;
2829
import java.lang.reflect.Method;
2930
import java.util.ArrayList;
@@ -39,6 +40,7 @@
3940
import lombok.eclipse.TransformEclipseAST;
4041
import lombok.eclipse.handlers.EclipseHandlerUtil;
4142
import lombok.experimental.ExtensionMethod;
43+
import lombok.permit.Permit;
4244

4345
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
4446
import org.eclipse.jdt.internal.compiler.ast.Annotation;
@@ -293,6 +295,13 @@ public static TypeBinding resolveType(TypeBinding resolvedType, MessageSend meth
293295
methodCall.actualReceiverType = extensionMethod.declaringClass;
294296
methodCall.binding = fixedBinding;
295297
methodCall.resolvedType = methodCall.binding.returnType;
298+
if (Reflection.argumentTypes != null) {
299+
try {
300+
Reflection.argumentTypes.set(methodCall, argumentTypes.toArray(new TypeBinding[0]));
301+
} catch (IllegalAccessException ignore) {
302+
// ignore
303+
}
304+
}
296305
}
297306
return methodCall.resolvedType;
298307
}
@@ -329,4 +338,18 @@ private static NameReference createNameRef(TypeBinding typeBinding, ASTNode sour
329338
return new QualifiedNameReference(sources, poss, source.sourceStart, source.sourceEnd);
330339
}
331340
}
341+
342+
private static final class Reflection {
343+
public static final Field argumentTypes;
344+
345+
static {
346+
Field a = null;
347+
try {
348+
a = Permit.getField(MessageSend.class, "argumentTypes");
349+
} catch (Throwable t) {
350+
//ignore - old eclipse versions don't know this one
351+
}
352+
argumentTypes = a;
353+
}
354+
}
332355
}

0 commit comments

Comments
 (0)
Please sign in to comment.