@@ -842,7 +842,7 @@ void ASTMangler::appendSymbolKind(SymbolKind SKind) {
842
842
case SymbolKind::DynamicThunk: return appendOperator (" TD" );
843
843
case SymbolKind::SwiftAsObjCThunk: return appendOperator (" To" );
844
844
case SymbolKind::ObjCAsSwiftThunk: return appendOperator (" TO" );
845
- case SymbolKind::DistributedThunk: return appendOperator (" Td " );
845
+ case SymbolKind::DistributedThunk: return appendOperator (" TE " );
846
846
}
847
847
}
848
848
@@ -1023,6 +1023,41 @@ void ASTMangler::appendOpaqueDeclName(const OpaqueTypeDecl *opaqueDecl) {
1023
1023
}
1024
1024
}
1025
1025
1026
+ void ASTMangler::appendExistentialLayout (
1027
+ const ExistentialLayout &layout, GenericSignature sig,
1028
+ const ValueDecl *forDecl) {
1029
+ bool First = true ;
1030
+ bool DroppedRequiresClass = false ;
1031
+ bool SawRequiresClass = false ;
1032
+ for (Type protoTy : layout.getProtocols ()) {
1033
+ auto proto = protoTy->castTo <ProtocolType>()->getDecl ();
1034
+ // If we aren't allowed to emit marker protocols, suppress them here.
1035
+ if (!AllowMarkerProtocols && proto->isMarkerProtocol ()) {
1036
+ if (proto->requiresClass ())
1037
+ DroppedRequiresClass = true ;
1038
+
1039
+ continue ;
1040
+ }
1041
+
1042
+ if (proto->requiresClass ())
1043
+ SawRequiresClass = true ;
1044
+
1045
+ appendProtocolName (protoTy->castTo <ProtocolType>()->getDecl ());
1046
+ appendListSeparator (First);
1047
+ }
1048
+ if (First)
1049
+ appendOperator (" y" );
1050
+
1051
+ if (auto superclass = layout.explicitSuperclass ) {
1052
+ appendType (superclass, sig, forDecl);
1053
+ return appendOperator (" Xc" );
1054
+ } else if (layout.hasExplicitAnyObject ||
1055
+ (DroppedRequiresClass && !SawRequiresClass)) {
1056
+ return appendOperator (" Xl" );
1057
+ }
1058
+ return appendOperator (" p" );
1059
+ }
1060
+
1026
1061
// / Mangle a type into the buffer.
1027
1062
// /
1028
1063
void ASTMangler::appendType (Type type, GenericSignature sig,
@@ -1199,31 +1234,15 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
1199
1234
return appendOperator (" t" );
1200
1235
1201
1236
case TypeKind::Protocol: {
1202
- bool First = true ;
1203
- appendProtocolName (cast<ProtocolType>(tybase)->getDecl ());
1204
- appendListSeparator (First);
1205
- return appendOperator (" p" );
1237
+ return appendExistentialLayout (
1238
+ ExistentialLayout (cast<ProtocolType>(tybase)), sig, forDecl);
1206
1239
}
1207
1240
1208
1241
case TypeKind::ProtocolComposition: {
1209
1242
// We mangle ProtocolType and ProtocolCompositionType using the
1210
1243
// same production:
1211
- bool First = true ;
1212
1244
auto layout = type->getExistentialLayout ();
1213
- for (Type protoTy : layout.getProtocols ()) {
1214
- appendProtocolName (protoTy->castTo <ProtocolType>()->getDecl ());
1215
- appendListSeparator (First);
1216
- }
1217
- if (First)
1218
- appendOperator (" y" );
1219
-
1220
- if (auto superclass = layout.explicitSuperclass ) {
1221
- appendType (superclass, sig, forDecl);
1222
- return appendOperator (" Xc" );
1223
- } else if (layout.hasExplicitAnyObject ) {
1224
- return appendOperator (" Xl" );
1225
- }
1226
- return appendOperator (" p" );
1245
+ return appendExistentialLayout (layout, sig, forDecl);
1227
1246
}
1228
1247
1229
1248
case TypeKind::UnboundGeneric:
@@ -2220,6 +2239,8 @@ void ASTMangler::appendModule(const ModuleDecl *module,
2220
2239
// / Mangle the name of a protocol as a substitution candidate.
2221
2240
void ASTMangler::appendProtocolName (const ProtocolDecl *protocol,
2222
2241
bool allowStandardSubstitution) {
2242
+ assert (AllowMarkerProtocols || !protocol->isMarkerProtocol ());
2243
+
2223
2244
if (allowStandardSubstitution && tryAppendStandardSubstitution (protocol))
2224
2245
return ;
2225
2246
@@ -2370,6 +2391,8 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl) {
2370
2391
appendOperator (" a" );
2371
2392
break ;
2372
2393
case DeclKind::Protocol:
2394
+ assert (AllowMarkerProtocols ||
2395
+ !cast<ProtocolDecl>(decl)->isMarkerProtocol ());
2373
2396
appendOperator (" P" );
2374
2397
break ;
2375
2398
case DeclKind::Class:
@@ -2689,6 +2712,11 @@ void ASTMangler::appendRequirement(const Requirement &reqt,
2689
2712
case RequirementKind::Layout: {
2690
2713
} break ;
2691
2714
case RequirementKind::Conformance: {
2715
+ // If we don't allow marker protocols but we have one here, skip it.
2716
+ if (!AllowMarkerProtocols &&
2717
+ reqt.getProtocolDecl ()->isMarkerProtocol ())
2718
+ return ;
2719
+
2692
2720
appendProtocolName (reqt.getProtocolDecl ());
2693
2721
} break ;
2694
2722
case RequirementKind::Superclass:
@@ -3226,6 +3254,12 @@ void ASTMangler::appendAnyProtocolConformance(
3226
3254
GenericSignature genericSig,
3227
3255
CanType conformingType,
3228
3256
ProtocolConformanceRef conformance) {
3257
+ // If we have a conformance to a marker protocol but we aren't allowed to
3258
+ // emit marker protocols, skip it.
3259
+ if (!AllowMarkerProtocols &&
3260
+ conformance.getRequirement ()->isMarkerProtocol ())
3261
+ return ;
3262
+
3229
3263
if (conformingType->isTypeParameter ()) {
3230
3264
assert (genericSig && " Need a generic signature to resolve conformance" );
3231
3265
auto path = genericSig->getConformanceAccessPath (conformingType,
0 commit comments