diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2020-04-23 09:59:36 +0200 |
---|---|---|
committer | Rawi01 <Rawi01@users.noreply.github.com> | 2020-04-23 09:59:36 +0200 |
commit | 3d90a51163354930eeea0e26c2b0a567af8e96be (patch) | |
tree | a764eb05ce5da22b14743a8c53f174f5062e863f /src/eclipseAgent/lombok/eclipse | |
parent | 39b733ab805f541a0834fb9cc501dc8b90567aa9 (diff) | |
download | lombok-3d90a51163354930eeea0e26c2b0a567af8e96be.tar.gz lombok-3d90a51163354930eeea0e26c2b0a567af8e96be.tar.bz2 lombok-3d90a51163354930eeea0e26c2b0a567af8e96be.zip |
Added tests for ExtensionMethod
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java index c4b0153c..1a1f2274 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java @@ -301,18 +301,23 @@ public class PatchExtensionMethod { // If the extension method uses varargs, the last fixed binding parameter is an array but // the method arguments are not. Even thought we already know that the method is fine we still // have to compare each parameter with the type of the array to support autoboxing/unboxing. - boolean isVararg = false; + boolean isVarargs = fixedBinding.isVarargs(); for (int i = 0, iend = arguments.size(); i < iend; i++) { Expression arg = arguments.get(i); TypeBinding[] parameters = fixedBinding.parameters; - TypeBinding param = isVararg ? parameters[parameters.length - 1].leafComponentType() : parameters[i]; + TypeBinding param; + if (isVarargs && i >= parameters.length - 1) { + // Extract the array element type for all vararg arguments + param = parameters[parameters.length - 1].leafComponentType(); + } else { + param = parameters[i]; + } // Resolve types for lambdas if (arg instanceof FunctionalExpression) { arg.setExpectedType(param); arg.resolveType(scope); } if (arg.resolvedType != null) { - isVararg |= param.isArrayType() != arg.resolvedType.isArrayType(); if (!param.isBaseType() && arg.resolvedType.isBaseType()) { int id = arg.resolvedType.id; arg.implicitConversion = TypeIds.BOXING | (id + (id << 4)); // magic see TypeIds |