@@ -1141,6 +1141,15 @@ void ASTMangler::appendExistentialLayout(
1141
1141
bool DroppedRequiresClass = false ;
1142
1142
bool SawRequiresClass = false ;
1143
1143
for (auto proto : layout.getProtocols ()) {
1144
+ // Skip invertible protocols
1145
+ //
1146
+ // TODO: reconsituteInverses so the absence of such protocols gets mangled.
1147
+ // I think here we need to see if any protocols inheritsFrom
1148
+ // Copyable/Escapable, and if not, and none of those are found in the layout
1149
+ // then it must have had an inverse.
1150
+ if (proto->getInvertibleProtocolKind ())
1151
+ continue ;
1152
+
1144
1153
// If we aren't allowed to emit marker protocols, suppress them here.
1145
1154
if (!AllowMarkerProtocols && proto->isMarkerProtocol ()) {
1146
1155
if (proto->requiresClass ())
@@ -2996,14 +3005,28 @@ void ASTMangler::appendTypeListElement(Identifier name, Type elementType,
2996
3005
appendOperator (" d" );
2997
3006
}
2998
3007
3008
+ // / Filters out requirements stating that a type conforms to one of the
3009
+ // / invertible protocols.
3010
+ // / TODO: reconsituteInverses so the absence of conformances gets mangled
3011
+ static void withoutInvertibleRequirements (ArrayRef<Requirement> requirements,
3012
+ SmallVector<Requirement, 4 > &output) {
3013
+ for (auto req : requirements) {
3014
+ // Skip conformance requirements for invertible protocols.
3015
+ if (req.getKind () == RequirementKind::Conformance
3016
+ && req.getProtocolDecl ()->getInvertibleProtocolKind ())
3017
+ continue ;
3018
+
3019
+ output.push_back (req);
3020
+ }
3021
+ }
3022
+
2999
3023
bool ASTMangler::appendGenericSignature (GenericSignature sig,
3000
3024
GenericSignature contextSig) {
3001
3025
auto canSig = sig.getCanonicalSignature ();
3002
3026
3003
3027
unsigned initialParamDepth;
3004
3028
ArrayRef<CanTypeWrapper<GenericTypeParamType>> genericParams;
3005
- ArrayRef<Requirement> requirements;
3006
- SmallVector<Requirement, 4 > requirementsBuffer;
3029
+ SmallVector<Requirement, 4 > requirements;
3007
3030
if (contextSig) {
3008
3031
// If the signature is the same as the context signature, there's nothing
3009
3032
// to do.
@@ -3033,16 +3056,16 @@ bool ASTMangler::appendGenericSignature(GenericSignature sig,
3033
3056
contextSig.getRequirements ().empty ()) {
3034
3057
initialParamDepth = 0 ;
3035
3058
genericParams = canSig.getGenericParams ();
3036
- requirements = canSig.getRequirements ();
3059
+ withoutInvertibleRequirements ( canSig.getRequirements (), requirements );
3037
3060
} else {
3038
- requirementsBuffer = canSig. requirementsNotSatisfiedBy (contextSig);
3039
- requirements = requirementsBuffer ;
3061
+ withoutInvertibleRequirements (
3062
+ canSig. requirementsNotSatisfiedBy (contextSig), requirements) ;
3040
3063
}
3041
3064
} else {
3042
3065
// Use the complete canonical signature.
3043
3066
initialParamDepth = 0 ;
3044
3067
genericParams = canSig.getGenericParams ();
3045
- requirements = canSig.getRequirements ();
3068
+ withoutInvertibleRequirements ( canSig.getRequirements (), requirements );
3046
3069
}
3047
3070
3048
3071
if (genericParams.empty () && requirements.empty ())
0 commit comments