@@ -117,6 +117,7 @@ public MethodExecutor resolve(EvaluationContext context, Object targetObject, St
117
117
TypeConverter typeConverter = context .getTypeConverter ();
118
118
Class <?> type = (targetObject instanceof Class ? (Class <?>) targetObject : targetObject .getClass ());
119
119
ArrayList <Method > methods = new ArrayList <>(getMethods (type , targetObject ));
120
+ methods .removeIf (method -> !method .getName ().equals (name ));
120
121
121
122
// If a filter is registered for this type, call it
122
123
MethodFilter filter = (this .filters != null ? this .filters .get (type ) : null );
@@ -160,48 +161,46 @@ else if (m1.isVarArgs() && !m2.isVarArgs()) {
160
161
boolean multipleOptions = false ;
161
162
162
163
for (Method method : methodsToIterate ) {
163
- if (method .getName ().equals (name )) {
164
- int paramCount = method .getParameterCount ();
165
- List <TypeDescriptor > paramDescriptors = new ArrayList <>(paramCount );
166
- for (int i = 0 ; i < paramCount ; i ++) {
167
- paramDescriptors .add (new TypeDescriptor (new MethodParameter (method , i )));
168
- }
169
- ReflectionHelper .ArgumentsMatchInfo matchInfo = null ;
170
- if (method .isVarArgs () && argumentTypes .size () >= (paramCount - 1 )) {
171
- // *sigh* complicated
172
- matchInfo = ReflectionHelper .compareArgumentsVarargs (paramDescriptors , argumentTypes , typeConverter );
173
- }
174
- else if (paramCount == argumentTypes .size ()) {
175
- // Name and parameter number match, check the arguments
176
- matchInfo = ReflectionHelper .compareArguments (paramDescriptors , argumentTypes , typeConverter );
164
+ int paramCount = method .getParameterCount ();
165
+ List <TypeDescriptor > paramDescriptors = new ArrayList <>(paramCount );
166
+ for (int i = 0 ; i < paramCount ; i ++) {
167
+ paramDescriptors .add (new TypeDescriptor (new MethodParameter (method , i )));
168
+ }
169
+ ReflectionHelper .ArgumentsMatchInfo matchInfo = null ;
170
+ if (method .isVarArgs () && argumentTypes .size () >= (paramCount - 1 )) {
171
+ // *sigh* complicated
172
+ matchInfo = ReflectionHelper .compareArgumentsVarargs (paramDescriptors , argumentTypes , typeConverter );
173
+ }
174
+ else if (paramCount == argumentTypes .size ()) {
175
+ // Name and parameter number match, check the arguments
176
+ matchInfo = ReflectionHelper .compareArguments (paramDescriptors , argumentTypes , typeConverter );
177
+ }
178
+ if (matchInfo != null ) {
179
+ if (matchInfo .isExactMatch ()) {
180
+ return new ReflectiveMethodExecutor (method , type );
177
181
}
178
- if (matchInfo != null ) {
179
- if (matchInfo .isExactMatch ()) {
180
- return new ReflectiveMethodExecutor (method , type );
181
- }
182
- else if (matchInfo .isCloseMatch ()) {
183
- if (this .useDistance ) {
184
- int matchDistance = ReflectionHelper .getTypeDifferenceWeight (paramDescriptors , argumentTypes );
185
- if (closeMatch == null || matchDistance < closeMatchDistance ) {
186
- // This is a better match...
187
- closeMatch = method ;
188
- closeMatchDistance = matchDistance ;
189
- }
190
- }
191
- else {
192
- // Take this as a close match if there isn't one already
193
- if (closeMatch == null ) {
194
- closeMatch = method ;
195
- }
182
+ else if (matchInfo .isCloseMatch ()) {
183
+ if (this .useDistance ) {
184
+ int matchDistance = ReflectionHelper .getTypeDifferenceWeight (paramDescriptors , argumentTypes );
185
+ if (closeMatch == null || matchDistance < closeMatchDistance ) {
186
+ // This is a better match...
187
+ closeMatch = method ;
188
+ closeMatchDistance = matchDistance ;
196
189
}
197
190
}
198
- else if (matchInfo .isMatchRequiringConversion ()) {
199
- if (matchRequiringConversion != null ) {
200
- multipleOptions = true ;
191
+ else {
192
+ // Take this as a close match if there isn't one already
193
+ if (closeMatch == null ) {
194
+ closeMatch = method ;
201
195
}
202
- matchRequiringConversion = method ;
203
196
}
204
197
}
198
+ else if (matchInfo .isMatchRequiringConversion ()) {
199
+ if (matchRequiringConversion != null ) {
200
+ multipleOptions = true ;
201
+ }
202
+ matchRequiringConversion = method ;
203
+ }
205
204
}
206
205
}
207
206
if (closeMatch != null ) {
0 commit comments