Skip to content

Commit f6b58cc

Browse files
committed
[ASTDemangler] Reconstruct protocol composition types with ExistentialType
when explicit existentials are enabled.
1 parent 1e65a3d commit f6b58cc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/AST/ASTDemangler.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,11 @@ Type ASTBuilder::createProtocolCompositionType(
589589
members.push_back(protocol->getDeclaredInterfaceType());
590590
if (superclass && superclass->getClassOrBoundGenericClass())
591591
members.push_back(superclass);
592-
return ProtocolCompositionType::get(Ctx, members, isClassBound);
592+
Type composition = ProtocolCompositionType::get(Ctx, members, isClassBound);
593+
if (Ctx.LangOpts.EnableExplicitExistentialTypes) {
594+
composition = ExistentialType::get(composition);
595+
}
596+
return composition;
593597
}
594598

595599
static MetatypeRepresentation
@@ -607,6 +611,8 @@ getMetatypeRepresentation(ImplMetatypeRepresentation repr) {
607611

608612
Type ASTBuilder::createExistentialMetatypeType(Type instance,
609613
Optional<Demangle::ImplMetatypeRepresentation> repr) {
614+
if (auto existential = instance->getAs<ExistentialType>())
615+
instance = existential->getConstraintType();
610616
if (!instance->isAnyExistentialType())
611617
return Type();
612618
if (!repr)

0 commit comments

Comments
 (0)