Skip to content

Commit 4405c47

Browse files
authored
Merge pull request #9410 from eeckstein/anyobj_mangling
2 parents 40c05b3 + dfa6582 commit 4405c47

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/Demangling/OldRemangler.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ namespace {
285285
void mangleNominalType(Node *node, char basicKind, EntityContext &ctx);
286286

287287
void mangleProtocolWithoutPrefix(Node *node);
288-
void mangleProtocolListWithoutPrefix(Node *node);
288+
void mangleProtocolListWithoutPrefix(Node *node,
289+
Node *additionalProto = nullptr);
289290

290291
void mangleEntityContext(Node *node, EntityContext &ctx);
291292
void mangleEntityType(Node *node, EntityContext &ctx);
@@ -1215,14 +1216,18 @@ void Remangler::mangleProtocolList(Node *node) {
12151216
mangleProtocolListWithoutPrefix(node);
12161217
}
12171218

1218-
void Remangler::mangleProtocolListWithoutPrefix(Node *node) {
1219+
void Remangler::mangleProtocolListWithoutPrefix(Node *node,
1220+
Node *additionalProto) {
12191221
assert(node->getKind() == Node::Kind::ProtocolList);
12201222
assert(node->getNumChildren() == 1);
12211223
auto typeList = node->begin()[0];
12221224
assert(typeList->getKind() == Node::Kind::TypeList);
12231225
for (auto &child : *typeList) {
12241226
mangleProtocolWithoutPrefix(child);
12251227
}
1228+
if (additionalProto) {
1229+
mangleProtocolWithoutPrefix(additionalProto);
1230+
}
12261231
Out << '_';
12271232
}
12281233

@@ -1674,8 +1679,11 @@ void Remangler::mangleProtocolListWithClass(Node *node) {
16741679
}
16751680

16761681
void Remangler::mangleProtocolListWithAnyObject(Node *node) {
1677-
Out << "Xl";
1678-
mangleProtocolListWithoutPrefix(node->getChild(0));
1682+
Node *P = Factory.createNode(Node::Kind::Protocol);
1683+
P->addChild(Factory.createNode(Node::Kind::Module, "Swift"), Factory);
1684+
P->addChild(Factory.createNode(Node::Kind::Identifier, "AnyObject"), Factory);
1685+
Out << "P";
1686+
mangleProtocolListWithoutPrefix(node->getChild(0), /*additionalProto*/ P);
16791687
}
16801688

16811689
void Remangler::mangleVTableThunk(Node *node) {

test/stdlib/RuntimeObjC.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,10 @@ Runtime.test("Generic class ObjC runtime names") {
376376

377377
expectEqual("_TtGC1a12GenericClassXcCS_9SomeClassS_9ProtocolA__",
378378
NSStringFromClass(GenericClass<ProtocolA & SomeClass>.self))
379-
expectEqual("_TtGC1a12GenericClassXlS_9ProtocolA__",
379+
expectEqual("_TtGC1a12GenericClassPS_9ProtocolAs9AnyObject__",
380380
NSStringFromClass(GenericClass<ProtocolA & AnyObject>.self))
381+
expectEqual("_TtGC1a12GenericClassPs9AnyObject__",
382+
NSStringFromClass(GenericClass<AnyObject>.self))
381383

382384
expectEqual("_TtGC1a17MultiGenericClassGVS_13GenericStructSi_GOS_11GenericEnumGS2_Si___",
383385
NSStringFromClass(MultiGenericClass<GenericStruct<Int>,

0 commit comments

Comments
 (0)