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
spoon.support.reflect.declaration.CtTypeImpl.hasSameParameters(CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes) lacks an if condition without which a comparison between a non-array type parameter and a candidate executable with an array parameter can take place, leading to a wrong return value.
Source code you are trying to analyze/transform
No response
Source code for your Spoon processing
protectedbooleanhasSameParameters(CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes) {
if (candidate.getParameters().size() != parameterTypes.length) {
returnfalse;
}
for (inti = 0; (i < candidate.getParameters().size()) && (i < parameterTypes.length); i++) {
finalCtTypeReference<?> ctParameterType = candidate.getParameters().get(i).getType();
finalCtTypeReference<?> parameterType = parameterTypes[i];
if (parameterTypeinstanceofCtArrayTypeReference) {
if (ctParameterTypeinstanceofCtArrayTypeReference) {
if (!isSameParameter(candidate, ((CtArrayTypeReference) ctParameterType).getComponentType(), ((CtArrayTypeReference) parameterType).getComponentType())) {
returnfalse;
} else {
if (((CtArrayTypeReference) ctParameterType).getDimensionCount() != ((CtArrayTypeReference) parameterType).getDimensionCount()) {
returnfalse;
}
}
} else {
returnfalse;
}
<-- Conditionislackinghere, ifctParameterTypeisanArrayTypeRef.
} elseif (!isSameParameter(candidate, ctParameterType, parameterType)) {
returnfalse;
}
}
returntrue;
}
Actual output
No response
Expected output
protectedbooleanhasSameParameters(
CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes) {
if (candidate.getParameters().size() != parameterTypes.length) {
returnfalse;
}
for (inti = 0; (i < candidate.getParameters().size()) && (i < parameterTypes.length);
i++) {
finalCtTypeReference<?> ctParameterType =
candidate.getParameters().get(i).getType();
finalCtTypeReference<?> parameterType = parameterTypes[i];
if (parameterTypeinstanceofCtArrayTypeReference) {
if (ctParameterTypeinstanceofCtArrayTypeReference) {
if (!isSameParameter(candidate,
((CtArrayTypeReference) ctParameterType).getComponentType(),
((CtArrayTypeReference) parameterType).getComponentType())) {
returnfalse;
} else {
if (((CtArrayTypeReference) ctParameterType).getDimensionCount()
!= ((CtArrayTypeReference) parameterType).getDimensionCount()) {
returnfalse;
}
}
} else {
returnfalse;
}
//The following else if condition must be appended to fix the logic
} elseif (ctParameterTypeinstanceofCtArrayTypeReference) {
returnfalse;
} elseif (!isSameParameter(candidate, ctParameterType, parameterType)) {
returnfalse;
}
}
returntrue;
}
Spoon Version
11.0.1
JVM Version
Not a JVM version issue
What operating system are you using?
NixOS Vicuna, but not relevant for this bug
The text was updated successfully, but these errors were encountered:
I don't understand the problem. If you pass in a non-array parameter the type erasure will differ (Foo[] vs Foo) and the isSame check will fail. Can you provide a failing example? i.e. some source code using spoon where this produces wrong results?
Describe the bug
spoon.support.reflect.declaration.CtTypeImpl.hasSameParameters(CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes)
lacks an if condition without which a comparison between a non-array type parameter and a candidate executable with an array parameter can take place, leading to a wrong return value.Source code you are trying to analyze/transform
No response
Source code for your Spoon processing
Actual output
No response
Expected output
Spoon Version
11.0.1
JVM Version
Not a JVM version issue
What operating system are you using?
NixOS Vicuna, but not relevant for this bug
The text was updated successfully, but these errors were encountered: