aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2020-11-19 17:36:40 +0100
committerRawi01 <Rawi01@users.noreply.github.com>2020-11-25 08:54:17 +0100
commitdb80bb0a2168245dbae2e1ec565a830e92a7c684 (patch)
treebb4156e1294595b017d1f060551dbb7d307c32c2 /src/eclipseAgent/lombok/eclipse/agent
parente1f82ac4d132769cfc272dccfc916aeba7181718 (diff)
downloadlombok-db80bb0a2168245dbae2e1ec565a830e92a7c684.tar.gz
lombok-db80bb0a2168245dbae2e1ec565a830e92a7c684.tar.bz2
lombok-db80bb0a2168245dbae2e1ec565a830e92a7c684.zip
[fixes #2648] Reset inference context, remove generic information copy
In Java >= 8 ecj uses the inference context to resolve the generic information. This one is already set before lombok tries rewrite the method call. Simply copying the information does not cover all the different cases but reseting the inference contexts and running type inference again does.
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
index c916ca26..5f229955 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 The Project Lombok Authors.
+ * Copyright (C) 2012-2020 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
@@ -58,7 +58,6 @@ import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.Scope;
@@ -304,12 +303,13 @@ public class PatchExtensionMethod {
argumentTypes.add(argumentType);
}
- // Copy generic information. This one covers a few simple cases, more complex cases are still broken
- int typeVariables = extensionMethod.typeVariables.length;
- if (typeVariables > 0 && methodCall.receiver.resolvedType instanceof ParameterizedTypeBinding) {
- ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) methodCall.receiver.resolvedType;
- if (parameterizedTypeBinding.arguments != null && parameterizedTypeBinding.arguments.length == typeVariables) {
- methodCall.genericTypeArguments = parameterizedTypeBinding.arguments;
+ if (methodCall.receiver instanceof MessageSend) {
+ if (Reflection.inferenceContexts != null) {
+ try {
+ Permit.set(Reflection.inferenceContexts, methodCall.receiver, null);
+ } catch (IllegalAccessException ignore) {
+ // ignore
+ }
}
}
@@ -402,6 +402,7 @@ public class PatchExtensionMethod {
private static final class Reflection {
public static final Field argumentTypes = Permit.permissiveGetField(MessageSend.class, "argumentTypes");
public static final Field argumentsHaveErrors = Permit.permissiveGetField(MessageSend.class, "argumentsHaveErrors");
+ public static final Field inferenceContexts = Permit.permissiveGetField(MessageSend.class, "inferenceContexts");
private static final Class<?> functionalExpression;
private static final Constructor<?> polyTypeBindingConstructor;