@@ -92,17 +92,22 @@ private static boolean hasLambdaArgument(J.MethodInvocation method) {
92
92
return hasLambdaArgument ;
93
93
}
94
94
95
- // Check whether a method has overloading methods in the declaring class
96
- static boolean hasAmbiguousMethodOverloading (J .MethodInvocation method ) {
95
+ // Check whether a method has overloading methods in the declaring class
96
+ private static boolean hasAmbiguousMethodOverloading (J .MethodInvocation method ) {
97
97
JavaType .Method methodType = method .getMethodType ();
98
+ String methodName = methodType .getName ();
99
+ return methodType != null && hasAmbiguousMethodOverloading (methodType , method .getArguments (), methodName );
100
+ }
98
101
99
- if (methodType == null ) {
100
- return false ;
101
- }
102
- int numberOfArguments = method .getArguments ().size ();
102
+ static boolean hasAmbiguousMethodOverloading (MethodCall method ) {
103
+ JavaType .Method methodType = method .getMethodType ();
104
+ String methodName = methodType .getName ();
105
+ return methodType != null && hasAmbiguousMethodOverloading (methodType , method .getArguments (), methodName );
106
+ }
103
107
104
108
// TODO this is actually more complex in the presence of generics and inheritance
105
- String methodName = methodType .getName ();
109
+ static boolean hasAmbiguousMethodOverloading (JavaType .Method methodType , List <Expression > arguments , String methodName ) {
110
+ int numberOfArguments = arguments .size ();
106
111
107
112
//all methods of the given type
108
113
List <JavaType .Method > methodsOfType = Optional .of (methodType )
@@ -128,7 +133,7 @@ static boolean hasAmbiguousMethodOverloading(J.MethodInvocation method) {
128
133
// then there is no ambiguity
129
134
for (int i = 0 ; i < numberOfArguments ; i ++) {
130
135
int finalI = i ;
131
- if (method . getArguments () .get (i ) instanceof J .Lambda ) {
136
+ if (arguments .get (i ) instanceof J .Lambda ) {
132
137
long distinctElementsCount = potentiallyOverLoadedMethods .stream ()
133
138
.map (m -> m .getParameterTypes ().get (finalI ))
134
139
.distinct ().count ();
0 commit comments