@@ -149,43 +149,16 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
149
149
}
150
150
case MetadataKind::Existential: {
151
151
auto exis = static_cast <const ExistentialTypeMetadata *>(type);
152
- NodePointer proto_list;
153
152
154
153
std::vector<const ProtocolDescriptor *> protocols;
155
154
protocols.reserve (exis->Protocols .NumProtocols );
156
155
for (unsigned i = 0 , e = exis->Protocols .NumProtocols ; i < e; ++i)
157
156
protocols.push_back (exis->Protocols [i]);
158
157
159
- if (exis->getSuperclassConstraint ()) {
160
- // If there is a superclass constraint, we mangle it specially.
161
- proto_list = Dem.createNode (Node::Kind::ProtocolListWithClass);
162
- } else if (exis->isClassBounded ()) {
163
- // Check if the class constraint is implied by any of our
164
- // protocols.
165
- bool requiresClassImplicit = false ;
166
-
167
- for (auto *protocol : protocols) {
168
- if (protocol->Flags .getClassConstraint ()
169
- == ProtocolClassConstraint::Class)
170
- requiresClassImplicit = true ;
171
- }
172
-
173
- // If it was implied, we don't do anything special.
174
- if (requiresClassImplicit)
175
- proto_list = Dem.createNode (Node::Kind::ProtocolList);
176
- // If the existential type has an explicit AnyObject constraint,
177
- // we must mangle it as such.
178
- else
179
- proto_list = Dem.createNode (Node::Kind::ProtocolListWithAnyObject);
180
- } else {
181
- // Just a simple composition of protocols.
182
- proto_list = Dem.createNode (Node::Kind::ProtocolList);
183
- }
184
-
185
- NodePointer type_list = Dem.createNode (Node::Kind::TypeList);
186
-
158
+ auto type_list = Dem.createNode (Node::Kind::TypeList);
159
+ auto proto_list = Dem.createNode (Node::Kind::ProtocolList);
187
160
proto_list->addChild (type_list, Dem);
188
-
161
+
189
162
// Sort the protocols by their mangled names.
190
163
// The ordering in the existential type metadata is by metadata pointer,
191
164
// which isn't necessarily stable across invocations.
@@ -226,11 +199,39 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
226
199
type_list->addChild (protocolNode, Dem);
227
200
}
228
201
229
- if (auto *superclass = exis->getSuperclassConstraint ()) {
202
+ if (auto superclass = exis->getSuperclassConstraint ()) {
203
+ // If there is a superclass constraint, we mangle it specially.
204
+ auto result = Dem.createNode (Node::Kind::ProtocolListWithClass);
230
205
auto superclassNode = _swift_buildDemanglingForMetadata (superclass, Dem);
231
- proto_list->addChild (superclassNode, Dem);
206
+
207
+ result->addChild (proto_list, Dem);
208
+ result->addChild (superclassNode, Dem);
209
+ return result;
210
+ }
211
+
212
+ if (exis->isClassBounded ()) {
213
+ // Check if the class constraint is implied by any of our
214
+ // protocols.
215
+ bool requiresClassImplicit = false ;
216
+
217
+ for (auto *protocol : protocols) {
218
+ if (protocol->Flags .getClassConstraint ()
219
+ == ProtocolClassConstraint::Class)
220
+ requiresClassImplicit = true ;
221
+ }
222
+
223
+ // If it was implied, we don't do anything special.
224
+ if (requiresClassImplicit)
225
+ return proto_list;
226
+
227
+ // If the existential type has an explicit AnyObject constraint,
228
+ // we must mangle it as such.
229
+ auto result = Dem.createNode (Node::Kind::ProtocolListWithAnyObject);
230
+ result->addChild (proto_list, Dem);
231
+ return result;
232
232
}
233
233
234
+ // Just a simple composition of protocols.
234
235
return proto_list;
235
236
}
236
237
case MetadataKind::ExistentialMetatype: {
0 commit comments