Skip to content

Commit bd6f27b

Browse files
committed
Stop mapping opened archetypes "out of context".
These opened archetypes need to be bound within their context, so any mapping out of the context will need to be explicit and map to newly-created generic parameters.
1 parent 08e417c commit bd6f27b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,10 +1320,16 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
13201320

13211321
// type ::= archetype
13221322
case TypeKind::PrimaryArchetype:
1323-
case TypeKind::OpenedArchetype:
13241323
case TypeKind::SequenceArchetype:
13251324
llvm_unreachable("Cannot mangle free-standing archetypes");
13261325

1326+
case TypeKind::OpenedArchetype: {
1327+
// Opened archetypes have always been mangled via their interface type,
1328+
// although those manglings aren't used in any stable manner.
1329+
auto openedType = cast<OpenedArchetypeType>(tybase);
1330+
return appendType(openedType->getInterfaceType(), sig, forDecl);
1331+
}
1332+
13271333
case TypeKind::OpaqueTypeArchetype: {
13281334
auto opaqueType = cast<OpaqueTypeArchetypeType>(tybase);
13291335
auto opaqueDecl = opaqueType->getDecl();

lib/AST/GenericEnvironment.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ Type MapTypeOutOfContext::operator()(SubstitutableType *type) const {
242242
auto archetype = cast<ArchetypeType>(type);
243243
if (isa<OpaqueTypeArchetypeType>(archetype->getRoot()))
244244
return Type();
245-
245+
246+
// Leave opened archetypes alone; they're handled contextually.
247+
if (isa<OpenedArchetypeType>(archetype))
248+
return Type(type);
249+
246250
return archetype->getInterfaceType();
247251
}
248252

0 commit comments

Comments
 (0)