Skip to content

Commit

Permalink
type parameters inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Oct 22, 2016
1 parent 7541f28 commit 702de8c
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -243,7 +243,7 @@ public Type replaceTypeParams(Type type) {
if (type.isTypeVariable()) {
TypeParameterDeclaration typeParameter = type.asTypeParameter();
if (typeParameter.declaredOnType()) {
Optional<Type> typeParam = typeParamByName(typeParameter.getName());
Optional<Type> typeParam = typeParamValue(typeParameter);
if (typeParam.isPresent()) {
type = typeParam.get();
}
Expand Down Expand Up @@ -388,7 +388,7 @@ private static List<Type> deriveParams(TypeDeclaration typeDeclaration) {
}

@Deprecated
private Optional<Type> typeParamByName(String name) {
private Optional<Type> typeParamValue(TypeParameterDeclaration typeParameterDeclaration) {
List<Type> typeParameters = this.typeParametersValues();
TypeDeclaration objectType = typeSolver.solveType(Object.class.getCanonicalName());
ReferenceType objectRef = create(objectType, typeSolver);
Expand All @@ -404,7 +404,10 @@ private Optional<Type> typeParamByName(String name) {
}
int i = 0;
for (TypeParameterDeclaration tp : typeDeclaration.getTypeParameters()) {
if (tp.getName().equals(name)) {
if (tp.getName().equals(typeParameterDeclaration.getName())) {
if (!tp.getQualifiedName().equals(typeParameterDeclaration.getQualifiedName())) {
throw new IllegalArgumentException();
}
return Optional.of(typeParameters.get(i));
}
i++;
Expand Down

0 comments on commit 702de8c

Please sign in to comment.