Skip to content

Commit

Permalink
Merge pull request #5050 from egranata/i-like-self
Browse files Browse the repository at this point in the history
Teach TypeReconstruction how to look through associated types of the Self protocol
  • Loading branch information
Enrico Granata committed Sep 28, 2016
2 parents 3f0adbd + 6a1d11b commit b52f324
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;

This comment has been minimized.

Copy link
@slavapestov

slavapestov Sep 28, 2016

Member

Is there a test for this in lldb?

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 b52f324

Please sign in to comment.