Skip to content

Commit

Permalink
Fix for issue #824
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Dec 14, 2024
1 parent e5b1ae2 commit f9d189a
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,13 @@ else if((parentFieldDeclarationMap != null && parentFieldDeclarationMap.contains
}
}
int i=0;
int originalExactlyMatchingArguments = 0;
for(UMLParameter parameter : operation.getParametersWithoutReturnType()) {
UMLType parameterType = parameter.getType();
if(inferredArgumentTypes.size() > i && inferredArgumentTypes.get(i) != null) {
if(exactlyMatchingArgumentType(parameterType, inferredArgumentTypes.get(i))) {
originalExactlyMatchingArguments++;
}
if(!parameterType.getClassType().equals(inferredArgumentTypes.get(i).toString()) &&
!parameterType.toString().equals(inferredArgumentTypes.get(i).toString()) &&
!compatibleTypes(parameter, inferredArgumentTypes.get(i), classDiff, modelDiff)) {
Expand All @@ -371,9 +375,34 @@ else if((parentFieldDeclarationMap != null && parentFieldDeclarationMap.contains
i++;
}
UMLType lastInferredArgumentType = inferredArgumentTypes.size() > 0 ? inferredArgumentTypes.get(inferredArgumentTypes.size()-1) : null;
return this.numberOfArguments == operation.getParameterTypeList().size() || varArgsMatch(operation, lastInferredArgumentType);
boolean result = this.numberOfArguments == operation.getParameterTypeList().size() || varArgsMatch(operation, lastInferredArgumentType);
if(result && classDiff != null) {
for(UMLOperation addedOperation : classDiff.getAddedOperations()) {
if(!addedOperation.equals(operation) && addedOperation.getName().equals(operation.getName())) {
int j = 0;
int exactlyMatchingArguments = 0;
for(UMLParameter parameter : addedOperation.getParametersWithoutReturnType()) {
UMLType parameterType = parameter.getType();
if(inferredArgumentTypes.size() > j && inferredArgumentTypes.get(j) != null) {
if(exactlyMatchingArgumentType(parameterType, inferredArgumentTypes.get(j))) {
exactlyMatchingArguments++;
}
}
j++;
}
if(exactlyMatchingArguments > originalExactlyMatchingArguments) {
return false;
}
}
}
}
return result;
}

private static boolean exactlyMatchingArgumentType(UMLType parameterType, UMLType argumentType) {
return parameterType.getClassType().equals(argumentType.toString()) || parameterType.toString().equals(argumentType.toString());
}

public static boolean compatibleTypes(UMLParameter parameter, UMLType type, UMLAbstractClassDiff classDiff, UMLModelDiff modelDiff) {
String type1 = parameter.getType().toString();
String type2 = type.toString();
Expand Down

0 comments on commit f9d189a

Please sign in to comment.