@@ -163,6 +163,8 @@ class PolymorphicConvention {
163163 CanType type, Args... args);
164164 bool considerType (CanType type, IsExact_t isExact,
165165 unsigned sourceIndex, MetadataPath &&path);
166+ bool considerTupleType (CanTupleType type, IsExact_t isExact,
167+ unsigned sourceIndex, MetadataPath &&path);
166168
167169 // / Testify to generic parameters in the Self type of a protocol
168170 // / witness method.
@@ -354,6 +356,15 @@ bool PolymorphicConvention::considerType(CanType type, IsExact_t isExact,
354356 std::move (path), callbacks);
355357}
356358
359+ bool PolymorphicConvention::considerTupleType (CanTupleType type, IsExact_t isExact,
360+ unsigned sourceIndex,
361+ MetadataPath &&path) {
362+ FulfillmentMapCallback callbacks (*this );
363+ return Fulfillments.searchTupleTypeMetadata (IGM, type, isExact,
364+ MetadataState::Complete, sourceIndex,
365+ std::move (path), callbacks);
366+ }
367+
357368void PolymorphicConvention::considerWitnessSelf (CanSILFunctionType fnType) {
358369 CanType selfTy = fnType->getSelfInstanceType (
359370 IGM.getSILModule (), IGM.getMaximalTypeExpansionContext ());
@@ -362,13 +373,17 @@ void PolymorphicConvention::considerWitnessSelf(CanSILFunctionType fnType) {
362373 // First, bind type metadata for Self.
363374 Sources.emplace_back (MetadataSource::Kind::SelfMetadata, selfTy);
364375
365- if (selfTy->is <GenericTypeParamType>()) {
366- // The Self type is abstract, so we can fulfill its metadata from
367- // the Self metadata parameter.
368- addSelfMetadataFulfillment (selfTy);
369- }
376+ if (auto tupleTy = dyn_cast<TupleType>(selfTy)) {
377+ considerTupleType (tupleTy, IsInexact, Sources.size () - 1 , MetadataPath ());
378+ } else {
379+ if (isa<GenericTypeParamType>(selfTy)) {
380+ // The Self type is abstract, so we can fulfill its metadata from
381+ // the Self metadata parameter.
382+ addSelfMetadataFulfillment (selfTy);
383+ }
370384
371- considerType (selfTy, IsInexact, Sources.size () - 1 , MetadataPath ());
385+ considerType (selfTy, IsInexact, Sources.size () - 1 , MetadataPath ());
386+ }
372387
373388 // The witness table for the Self : P conformance can be
374389 // fulfilled from the Self witness table parameter.
0 commit comments