@@ -477,8 +477,8 @@ enum class ConventionsKind : uint8_t {
477
477
}
478
478
}
479
479
480
- void visitSelfType (AbstractionPattern origType, CanType substType,
481
- SILFunctionTypeRepresentation rep) {
480
+ void visitSharedType (AbstractionPattern origType, CanType substType,
481
+ SILFunctionTypeRepresentation rep) {
482
482
NextOrigParamIndex++;
483
483
484
484
auto &substTL =
@@ -548,16 +548,29 @@ enum class ConventionsKind : uint8_t {
548
548
/* canonicalVararg*/ true )
549
549
->getCanonicalType ();
550
550
CanTupleType tty = dyn_cast<TupleType>(ty);
551
- if (!tty || (origType.isTypeParameter () && !tty->hasInOutElement ())) {
552
- visit (origType, ty);
553
- return ;
554
- }
555
-
556
551
// If the abstraction pattern is opaque, and the tuple type is
557
552
// materializable -- if it doesn't contain an l-value type -- then it's
558
553
// a valid target for substitution and we should not expand it.
554
+ if (!tty || (origType.isTypeParameter () && !tty->hasInOutElement ())) {
555
+ auto flags = (params.size () == 1 )
556
+ ? params.front ().getParameterFlags ()
557
+ : ParameterTypeFlags ();
558
+ if (flags.isShared ()) {
559
+ visitSharedType (origType, ty, extInfo.getSILRepresentation ());
560
+ } else {
561
+ visit (origType, ty);
562
+ }
563
+ return ;
564
+ }
565
+
559
566
for (auto i : indices (tty.getElementTypes ())) {
560
- visit (origType.getTupleElementType (i), tty.getElementType (i));
567
+ if (tty->getElement (i).getParameterFlags ().isShared ()) {
568
+ visitSharedType (origType.getTupleElementType (i),
569
+ tty.getElementType (i),
570
+ extInfo.getSILRepresentation ());
571
+ } else {
572
+ visit (origType.getTupleElementType (i), tty.getElementType (i));
573
+ }
561
574
}
562
575
return ;
563
576
}
@@ -569,15 +582,19 @@ enum class ConventionsKind : uint8_t {
569
582
CanType ty = params[i].getType ();
570
583
CanTupleType tty = dyn_cast<TupleType>(ty);
571
584
AbstractionPattern eltPattern = origType.getTupleElementType (i);
585
+ // If the abstraction pattern is opaque, and the tuple type is
586
+ // materializable -- if it doesn't contain an l-value type -- then it's
587
+ // a valid target for substitution and we should not expand it.
572
588
if (!tty || (eltPattern.isTypeParameter () && !tty->hasInOutElement ())) {
573
- visit (eltPattern, ty);
589
+ if (params[i].getParameterFlags ().isShared ()) {
590
+ visitSharedType (eltPattern, ty, extInfo.getSILRepresentation ());
591
+ } else {
592
+ visit (eltPattern, ty);
593
+ }
574
594
continue ;
575
595
}
576
596
577
597
assert (eltPattern.isTuple ());
578
- // If the abstraction pattern is opaque, and the tuple type is
579
- // materializable -- if it doesn't contain an l-value type -- then it's
580
- // a valid target for substitution and we should not expand it.
581
598
for (unsigned j = 0 ; j < eltPattern.getNumTupleElements (); ++j) {
582
599
visit (eltPattern.getTupleElementType (j), tty.getElementType (j));
583
600
}
@@ -586,9 +603,9 @@ enum class ConventionsKind : uint8_t {
586
603
// Process the self parameter. Note that we implicitly drop self
587
604
// if this is a static foreign-self import.
588
605
if (!Foreign.Self .isImportAsMember ()) {
589
- visitSelfType (origType.getTupleElementType (numNonSelfParams),
590
- params[numNonSelfParams].getType (),
591
- extInfo.getSILRepresentation ());
606
+ visitSharedType (origType.getTupleElementType (numNonSelfParams),
607
+ params[numNonSelfParams].getType (),
608
+ extInfo.getSILRepresentation ());
592
609
}
593
610
594
611
// Clear the foreign-self handler for safety.
0 commit comments