@@ -1022,6 +1022,14 @@ AbstractionPattern AbstractionPattern::getDynamicSelfSelfType() const {
1022
1022
cast<DynamicSelfType>(getType ()).getSelfType ());
1023
1023
}
1024
1024
1025
+ AbstractionPattern
1026
+ AbstractionPattern::getProtocolCompositionMemberType (unsigned argIndex) const {
1027
+ assert (getKind () == Kind::Type);
1028
+ return AbstractionPattern (getGenericSubstitutions (),
1029
+ getGenericSignature (),
1030
+ cast<ProtocolCompositionType>(getType ()).getMembers ()[argIndex]);
1031
+ }
1032
+
1025
1033
AbstractionPattern
1026
1034
AbstractionPattern::getParameterizedProtocolArgType (unsigned argIndex) const {
1027
1035
assert (getKind () == Kind::Type);
@@ -2699,22 +2707,44 @@ class SubstFunctionTypePatternVisitor
2699
2707
CanType visitParameterizedProtocolType (CanParameterizedProtocolType ppt,
2700
2708
AbstractionPattern pattern) {
2701
2709
// Recurse into the arguments of the parameterized protocol.
2702
- SmallVector<Type, 4 > substArgs;
2703
2710
auto origPPT = pattern.getAs <ParameterizedProtocolType>();
2704
2711
if (!origPPT)
2705
2712
return ppt;
2706
2713
2714
+ SmallVector<Type, 4 > substArgs;
2707
2715
for (unsigned i = 0 ; i < ppt->getArgs ().size (); ++i) {
2708
2716
auto argTy = ppt.getArgs ()[i];
2709
2717
auto origArgTy = pattern.getParameterizedProtocolArgType (i);
2710
- auto substEltTy = visit (argTy, origArgTy);
2711
- substArgs.push_back (substEltTy );
2718
+ auto substArgTy = visit (argTy, origArgTy);
2719
+ substArgs.push_back (substArgTy );
2712
2720
}
2713
2721
2714
2722
return CanType (ParameterizedProtocolType::get (
2715
2723
TC.Context , ppt->getBaseType (), substArgs));
2716
2724
}
2717
2725
2726
+ CanType visitProtocolCompositionType (CanProtocolCompositionType pct,
2727
+ AbstractionPattern pattern) {
2728
+ // Recurse into the arguments of the protocol composition.
2729
+ auto origPCT = pattern.getAs <ProtocolCompositionType>();
2730
+ if (!origPCT)
2731
+ return pct;
2732
+
2733
+ SmallVector<Type, 4 > substMembers;
2734
+ for (unsigned i = 0 ; i < pct->getMembers ().size (); ++i) {
2735
+ auto memberTy = CanType (pct->getMembers ()[i]);
2736
+ auto origMemberTy = pattern.getProtocolCompositionMemberType (i);
2737
+ auto substMemberTy = visit (memberTy, origMemberTy);
2738
+ substMembers.push_back (substMemberTy);
2739
+ }
2740
+
2741
+ return CanType (ProtocolCompositionType::get (
2742
+ TC.Context ,
2743
+ substMembers,
2744
+ pct->getInverses (),
2745
+ pct->hasExplicitAnyObject ()));
2746
+ }
2747
+
2718
2748
// / Visit a tuple pattern. Note that, because of vanishing tuples,
2719
2749
// / we can't handle this case by matching a tuple type in the
2720
2750
// / substituted type; we have to check for a tuple pattern in the
0 commit comments