Skip to content

Commit

Permalink
fix issue 1675
Browse files Browse the repository at this point in the history
  • Loading branch information
daans committed Jul 5, 2018
1 parent 88f0f44 commit a038f2f
Showing 1 changed file with 25 additions and 11 deletions.
Expand Up @@ -68,19 +68,33 @@ public SymbolReference<ResolvedTypeDeclaration> solveType(String name, TypeSolve
}

// Look into extended classes and implemented interfaces
for (ResolvedReferenceType ancestor : this.typeDeclaration.getAncestors()) {
try {
for (ResolvedTypeDeclaration internalTypeDeclaration : ancestor.getTypeDeclaration().internalTypes()) {
if (internalTypeDeclaration.getName().equals(name)) {
return SymbolReference.solved(internalTypeDeclaration);
}
}
} catch (UnsupportedOperationException e) {
// just continue using the next ancestor
ResolvedTypeDeclaration type = checkAncestorsForType(name, this.typeDeclaration);
return ((type != null) ? SymbolReference.solved(type) : context.getParent().solveType(name, typeSolver));
}

/**
* Recursively checks the ancestors of the {@param declaration} if an internal type is declared with a name equal
* to {@param name}.
* @return A ResolvedTypeDeclaration matching the {@param name}, null otherwise
*/
private ResolvedTypeDeclaration checkAncestorsForType(String name, ResolvedReferenceTypeDeclaration declaration) {
for (ResolvedReferenceType ancestor : declaration.getAncestors()) {
try {
for (ResolvedTypeDeclaration internalTypeDeclaration : ancestor.getTypeDeclaration().internalTypes()) {
if (internalTypeDeclaration.getName().equals(name)) {
return internalTypeDeclaration;
}
}
// check recursively the ancestors of this ancestor
ResolvedTypeDeclaration ancestorDeclaration = checkAncestorsForType(name, ancestor.getTypeDeclaration());
if (ancestorDeclaration != null) {
return ancestorDeclaration;
}
} catch (UnsupportedOperationException e) {
// just continue using the next ancestor
}
}

return context.getParent().solveType(name, typeSolver);
return null;
}

public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly, TypeSolver typeSolver) {
Expand Down

0 comments on commit a038f2f

Please sign in to comment.