@@ -2757,6 +2757,35 @@ void ASTMangler::appendDependentProtocolConformance(
2757
2757
}
2758
2758
}
2759
2759
2760
+ void ASTMangler::appendAnyProtocolConformance (
2761
+ CanGenericSignature genericSig,
2762
+ CanType conformingType,
2763
+ ProtocolConformanceRef conformance) {
2764
+ if (conformingType->isTypeParameter ()) {
2765
+ assert (genericSig && " Need a generic signature to resolve conformance" );
2766
+ auto path = genericSig->getConformanceAccessPath (conformingType,
2767
+ conformance.getAbstract ());
2768
+ appendDependentProtocolConformance (path);
2769
+ } else if (auto opaqueType = conformingType->getAs <OpaqueTypeArchetypeType>()) {
2770
+ GenericSignature opaqueSignature = opaqueType->getBoundSignature ();
2771
+ GenericTypeParamType *opaqueTypeParam = opaqueSignature->getGenericParams ().back ();
2772
+ ConformanceAccessPath conformanceAccessPath =
2773
+ opaqueSignature->getConformanceAccessPath (opaqueTypeParam,
2774
+ conformance.getAbstract ());
2775
+
2776
+ // Append the conformance access path with the signature of the opaque type.
2777
+ {
2778
+ llvm::SaveAndRestore<CanGenericSignature> savedSignature (
2779
+ CurGenericSignature, opaqueSignature.getCanonicalSignature ());
2780
+ appendDependentProtocolConformance (conformanceAccessPath);
2781
+ }
2782
+ appendType (conformingType);
2783
+ appendOperator (" HO" );
2784
+ } else {
2785
+ appendConcreteProtocolConformance (conformance.getConcrete ());
2786
+ }
2787
+ }
2788
+
2760
2789
void ASTMangler::appendConcreteProtocolConformance (
2761
2790
const ProtocolConformance *conformance) {
2762
2791
auto module = conformance->getDeclContext ()->getParentModule ();
@@ -2797,30 +2826,15 @@ void ASTMangler::appendConcreteProtocolConformance(
2797
2826
CanType canType = type->getCanonicalType (CurGenericSignature);
2798
2827
auto proto =
2799
2828
conditionalReq.getSecondType ()->castTo <ProtocolType>()->getDecl ();
2800
- if (canType->isTypeParameter ()) {
2801
- assert (CurGenericSignature &&
2802
- " Need a generic signature to resolve conformance" );
2803
- auto conformanceAccessPath =
2804
- CurGenericSignature->getConformanceAccessPath (type, proto);
2805
- appendDependentProtocolConformance (conformanceAccessPath);
2806
- } else if (auto opaqueType = canType->getAs <OpaqueTypeArchetypeType>()) {
2807
- GenericSignature opaqueSignature = opaqueType->getBoundSignature ();
2808
- GenericTypeParamType *opaqueTypeParam = opaqueSignature->getGenericParams ().back ();
2809
- ConformanceAccessPath conformanceAccessPath =
2810
- opaqueSignature->getConformanceAccessPath (opaqueTypeParam, proto);
2811
-
2812
- // Append the conformance access path with the signature of the opaque type.
2813
- {
2814
- llvm::SaveAndRestore<CanGenericSignature> savedSignature (
2815
- CurGenericSignature, opaqueSignature.getCanonicalSignature ());
2816
- appendDependentProtocolConformance (conformanceAccessPath);
2817
- }
2818
- appendType (canType);
2819
- appendOperator (" HO" );
2829
+
2830
+ ProtocolConformanceRef conformance;
2831
+
2832
+ if (canType->isTypeParameter () || canType->is <OpaqueTypeArchetypeType>()){
2833
+ conformance = ProtocolConformanceRef (proto);
2820
2834
} else {
2821
- auto conditionalConf = module ->lookupConformance (canType, proto);
2822
- appendConcreteProtocolConformance (conditionalConf.getConcrete ());
2835
+ conformance = module ->lookupConformance (canType, proto);
2823
2836
}
2837
+ appendAnyProtocolConformance (CurGenericSignature, canType, conformance);
2824
2838
appendListSeparator (firstRequirement);
2825
2839
break ;
2826
2840
}
0 commit comments