Give associated type declarations interface types.

This required moving a gross hack from the old archetype-based
type-opening code over to the new, generic type parameter-based
type-opening code. We need the ability to build conformances for types
involving type variables to address this case properly.


Swift SVN r9821
This commit is contained in:
Doug Gregor
2013-10-30 22:53:28 +00:00
parent b09cf2aa5c
commit 77264dc10f
3 changed files with 85 additions and 58 deletions

View File

@@ -404,6 +404,19 @@ Type ValueDecl::getInterfaceType() const {
if (auto nominal = dyn_cast<NominalTypeDecl>(this))
return nominal->computeInterfaceType();
if (auto assocType = dyn_cast<AssociatedTypeDecl>(this)) {
auto proto = cast<ProtocolDecl>(getDeclContext());
(void)proto->getType(); // make sure we've computed the type.
auto selfTy = proto->getGenericParamTypes()[0];
auto &ctx = getASTContext();
InterfaceTy = DependentMemberType::get(
selfTy,
const_cast<AssociatedTypeDecl *>(assocType),
ctx);
InterfaceTy = MetaTypeType::get(InterfaceTy, ctx);
return InterfaceTy;
}
return Type();
}