You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Look at the for loop, the first if branch, it only check the first type argument of the ParameterizedType and returned. When there are two type arguments, the result will be wrong.
private boolean isParameterizedTypeAssignable(ParameterizedType methodReturnType,
ParameterizedType failingMethodReturnType) {
Type[] methodActualArgs = methodReturnType.getActualTypeArguments();
Type[] failingMethodActualArgs = failingMethodReturnType.getActualTypeArguments();
if (methodActualArgs.length != failingMethodActualArgs.length) {
return false;
}
int startingIndex = 0;
for (int i = startingIndex; i < methodActualArgs.length; i++) {
Type methodArgType = methodActualArgs[i];
Type failingMethodArgType = failingMethodActualArgs[i];
if (methodArgType instanceof ParameterizedType && failingMethodArgType instanceof ParameterizedType) {
return isParameterizedTypeAssignable((ParameterizedType) methodArgType,
(ParameterizedType) failingMethodArgType);
}
if (methodArgType instanceof Class && failingMethodArgType instanceof Class
&& !failingMethodArgType.equals(methodArgType)) {
return false;
}
}
return true;
}
Thanks for looking into this.
Feel free to provide a Pull Request with respective unit tests to confirm the problem and of course the fix to keep existing tests and your new as green.
Look at the for loop, the first if branch, it only check the first type argument of the ParameterizedType and returned. When there are two type arguments, the result will be wrong.
Here's the test:
and the result is
true
, incorrect!I make some correction, here's the code:
and the result is
false
, which is correct.The text was updated successfully, but these errors were encountered: