@@ -113,7 +113,7 @@ private boolean isMatchingGenericMethod(@Nullable Object mock, @Nonnull String i
113
113
if (mockedClass != instance .getClass ()) {
114
114
GenericTypeReflection typeReflection = new GenericTypeReflection (mockedClass , null );
115
115
GenericSignature parsedSignature = typeReflection .parseSignature (genericSignature );
116
- return parsedSignature .satisfiesSignature (invokedMethod );
116
+ return parsedSignature .satisfiesSignature (invokedMethod ) && isMatchingMethodName ( invokedMethod ) ;
117
117
}
118
118
}
119
119
}
@@ -122,6 +122,9 @@ private boolean isMatchingGenericMethod(@Nullable Object mock, @Nonnull String i
122
122
}
123
123
124
124
private boolean isMatchingMethod (@ Nonnull String invokedMethod ) {
125
+ if (!isMatchingMethodName (invokedMethod )) {
126
+ return false ;
127
+ }
125
128
int returnTypeStartPos = getReturnTypePosition (invokedMethod );
126
129
127
130
if (returnTypeStartPos < 0 ) {
@@ -137,6 +140,12 @@ private boolean isMatchingMethod(@Nonnull String invokedMethod) {
137
140
return isReturnTypeOfRecordedMethodAssignableToReturnTypeOfInvokedMethod (invokedMethod , returnTypeStartPos );
138
141
}
139
142
143
+ private boolean isMatchingMethodName (@ Nonnull String invokedMethod ) {
144
+ int methodNameEndPos = invokedMethod .indexOf ('(' );
145
+ String methodName = invokedMethod .substring (0 , methodNameEndPos );
146
+ return getMethodNameAndDescription ().startsWith (methodName );
147
+ }
148
+
140
149
// Returns -1 if the method names or parameters are different.
141
150
private int getReturnTypePosition (@ Nonnull String invokedMethod ) {
142
151
String recordedMethod = getMethodNameAndDescription ();
0 commit comments