mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user