@@ -4833,8 +4833,30 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
4833
4833
if (!genericSig)
4834
4834
return substitutions;
4835
4835
4836
- // Find the superclass type with the context matching that of the member.
4837
4836
auto *ownerNominal = dc->getSelfNominalTypeDecl ();
4837
+
4838
+ // If the declaration context is Builtin.TheTupleType or an extension thereof,
4839
+ // the base type must be a tuple type. Build a pack type from the tuple's
4840
+ // elements and construct a substitution map replacing the generic parameter
4841
+ // of Builtin.TheTupleType with the pack.
4842
+ if (isa<BuiltinTupleDecl>(ownerNominal)) {
4843
+ SmallVector<Type, 2 > packElts;
4844
+ for (auto type : castTo<TupleType>()->getElementTypes ())
4845
+ packElts.push_back (type);
4846
+
4847
+ auto *packType = PackType::get (dc->getASTContext (), packElts);
4848
+
4849
+ assert (genericSig.getGenericParams ().size () == 1 );
4850
+ auto elementsParam = cast<SubstitutableType>(
4851
+ genericSig.getGenericParams ()[0 ]->getCanonicalType ());
4852
+ substitutions[elementsParam] = packType;
4853
+ return substitutions;
4854
+ }
4855
+
4856
+ // If the declaration context is a class or an extension thereof, the base
4857
+ // type must be a class, class-constrained archetype, or self-conforming
4858
+ // existential with a superclass bound. Get the base type's superclass type
4859
+ // for the corresponding declaration context.
4838
4860
if (auto *ownerClass = dyn_cast<ClassDecl>(ownerNominal)) {
4839
4861
baseTy = baseTy->getSuperclassForDecl (ownerClass,
4840
4862
/* usesArchetypes=*/ genericEnv != nullptr );
0 commit comments