Skip to content

Commit

Permalink
refactoring matching type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Oct 22, 2016
1 parent a631891 commit 9c4e9b3
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -95,24 +95,24 @@ private MethodUsage resolveMethodTypeParameters(MethodUsage methodUsage, List<Ty
// actualParamTypes, methodUsage.getDeclaration(), methodUsage));
}
}
Map<String, Type> matchedTypeParameters = new HashMap<>();
Map<TypeParameterDeclaration, Type> matchedTypeParameters = new HashMap<>();
for (int i = 0; i < actualParamTypes.size(); i++) {
Type expectedType = methodUsage.getParamType(i);
Type actualType = actualParamTypes.get(i);
matchTypeParameters(expectedType, actualType, matchedTypeParameters);
}
for (String tp : matchedTypeParameters.keySet()) {
methodUsage = methodUsage.replaceTypeParameterByName(tp, matchedTypeParameters.get(tp));
for (TypeParameterDeclaration tp : matchedTypeParameters.keySet()) {
methodUsage = methodUsage.replaceTypeParameterByName(tp.getName(), matchedTypeParameters.get(tp));
}
return methodUsage;
}

private void matchTypeParameters(Type expectedType, Type actualType, Map<String, Type> matchedTypeParameters) {
private void matchTypeParameters(Type expectedType, Type actualType, Map<TypeParameterDeclaration, Type> matchedTypeParameters) {
if (expectedType.isTypeVariable()) {
if (!expectedType.isTypeVariable()) {
throw new UnsupportedOperationException(actualType.getClass().getCanonicalName());
}
matchedTypeParameters.put(expectedType.asTypeParameter().getName(), actualType);
matchedTypeParameters.put(expectedType.asTypeParameter(), actualType);
} else if (expectedType.isArray()) {
if (!actualType.isArray()) {
throw new UnsupportedOperationException(actualType.getClass().getCanonicalName());
Expand Down

0 comments on commit 9c4e9b3

Please sign in to comment.