Skip to content

Commit

Permalink
Teach TypeReconstruction how to look through associated types of the …
Browse files Browse the repository at this point in the history
…Self protocol
  • Loading branch information
Enrico Granata committed Sep 28, 2016
1 parent ada1e82 commit 6a1d11b
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions lib/IDE/TypeReconstruction.cpp
Expand Up @@ -866,14 +866,27 @@ static void VisitNodeAssociatedTypeRef(
ArchetypeType *archetype = type->getAs<ArchetypeType>();
if (archetype) {
Identifier identifier = ast->getIdentifier(ident->getText());
if (archetype->hasNestedType(identifier)) {
Type nested = archetype->getNestedTypeValue(identifier);
if (nested) {
result._types.push_back(nested);
result._module = type_result._module;
return;
Type nested;
if (archetype->hasNestedType(identifier))
nested = archetype->getNestedTypeValue(identifier);
else if (ProtocolDecl *self_protocol = archetype->getSelfProtocol()) {
for (auto self_member: self_protocol->getMembers()) {
if (AssociatedTypeDecl *associated_decl = llvm::dyn_cast_or_null<AssociatedTypeDecl>(self_member)) {
if (associated_decl->hasName()) {
llvm::StringRef decl_name = associated_decl->getNameStr();
if (decl_name == ident->getText()) {
nested = associated_decl->getDeclaredType();
break;
}
}
}
}
}
if (nested) {
result._types.push_back(nested);
result._module = type_result._module;
return;
}
}
}
}
Expand Down

0 comments on commit 6a1d11b

Please sign in to comment.