Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Oct 22, 2016
1 parent dc093e9 commit 5dce72a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Expand Up @@ -100,29 +100,29 @@ public MethodUsage resolveTypeVariables(Context context, List<Type> parameterTyp

// We now look at the type parameter for the method which we can derive from the parameter types
// and then we replace them in the return type
Map<String, Type> determinedTypeParameters = new HashMap<>();
Map<TypeParameterDeclaration, Type> determinedTypeParameters = new HashMap<>();
for (int i = 0; i < getNumberOfParams(); i++) {
Type formalParamType = getParam(i).getType();
Type actualParamType = parameterTypes.get(i);
determineTypeParameters(determinedTypeParameters, formalParamType, actualParamType, typeSolver);
}

for (String determinedParam : determinedTypeParameters.keySet()) {
for (TypeParameterDeclaration determinedParam : determinedTypeParameters.keySet()) {
returnType = returnType.replaceParam(determinedParam, determinedTypeParameters.get(determinedParam));
}

return new MethodUsage(new JavaParserMethodDeclaration(wrappedNode, typeSolver), params, returnType);
}

private void determineTypeParameters(Map<String, Type> determinedTypeParameters, Type formalParamType, Type actualParamType, TypeSolver typeSolver) {
private void determineTypeParameters(Map<TypeParameterDeclaration, Type> determinedTypeParameters, Type formalParamType, Type actualParamType, TypeSolver typeSolver) {
if (actualParamType.isNull()) {
return;
}
if (actualParamType.isTypeVariable()) {
return;
}
if (formalParamType.isTypeVariable()) {
determinedTypeParameters.put(formalParamType.describe(), actualParamType);
determinedTypeParameters.put(formalParamType.asTypeParameter(), actualParamType);
return;
}
if (formalParamType instanceof Wildcard) {
Expand Down
Expand Up @@ -122,29 +122,29 @@ public MethodUsage resolveTypeVariables(Context context, List<Type> parameterTyp

// We now look at the type parameter for the method which we can derive from the parameter types
// and then we replace them in the return type
Map<String, Type> determinedTypeParameters = new HashMap<>();
Map<TypeParameterDeclaration, Type> determinedTypeParameters = new HashMap<>();
for (int i = 0; i < getNumberOfParams(); i++) {
Type formalParamType = getParam(i).getType();
Type actualParamType = parameterTypes.get(i);
determineTypeParameters(determinedTypeParameters, formalParamType, actualParamType, typeSolver);
}

for (String determinedParam : determinedTypeParameters.keySet()) {
for (TypeParameterDeclaration determinedParam : determinedTypeParameters.keySet()) {
returnType = returnType.replaceParam(determinedParam, determinedTypeParameters.get(determinedParam));
}

return new MethodUsage(new ReflectionMethodDeclaration(method, typeSolver), params, returnType);
}

private void determineTypeParameters(Map<String, Type> determinedTypeParameters, Type formalParamType, Type actualParamType, TypeSolver typeSolver) {
private void determineTypeParameters(Map<TypeParameterDeclaration, Type> determinedTypeParameters, Type formalParamType, Type actualParamType, TypeSolver typeSolver) {
if (actualParamType.isNull()) {
return;
}
if (actualParamType.isTypeVariable()) {
return;
}
if (formalParamType.isTypeVariable()) {
determinedTypeParameters.put(formalParamType.describe(), actualParamType);
determinedTypeParameters.put(formalParamType.asTypeParameter(), actualParamType);
return;
}
if (formalParamType instanceof Wildcard) {
Expand Down

0 comments on commit 5dce72a

Please sign in to comment.