@@ -134,8 +134,10 @@ class PolymorphicConvention {
134134
135135private:
136136 void initGenerics ();
137- void considerNewTypeSource (MetadataSource::Kind kind, unsigned paramIndex,
138- CanType type, IsExact_t isExact);
137+
138+ template <typename ...Args>
139+ void considerNewTypeSource (IsExact_t isExact, MetadataSource::Kind kind,
140+ CanType type, Args... args);
139141 bool considerType (CanType type, IsExact_t isExact,
140142 unsigned sourceIndex, MetadataPath &&path);
141143
@@ -302,14 +304,15 @@ void PolymorphicConvention::initGenerics() {
302304 Generics = FnType->getInvocationGenericSignature ();
303305}
304306
305- void PolymorphicConvention::considerNewTypeSource (MetadataSource::Kind kind,
306- unsigned paramIndex,
307+ template <typename ...Args>
308+ void PolymorphicConvention::considerNewTypeSource (IsExact_t isExact,
309+ MetadataSource::Kind kind,
307310 CanType type,
308- IsExact_t isExact ) {
311+ Args... args ) {
309312 if (!Fulfillments.isInterestingTypeForFulfillments (type)) return ;
310313
311314 // Prospectively add a source.
312- Sources.emplace_back (kind, paramIndex, type );
315+ Sources.emplace_back (kind, type, std::forward<Args>(args)... );
313316
314317 // Consider the source.
315318 if (!considerType (type, isExact, Sources.size () - 1 , MetadataPath ())) {
@@ -333,9 +336,7 @@ void PolymorphicConvention::considerWitnessSelf(CanSILFunctionType fnType) {
333336 auto conformance = fnType->getWitnessMethodConformanceOrInvalid ();
334337
335338 // First, bind type metadata for Self.
336- Sources.emplace_back (MetadataSource::Kind::SelfMetadata,
337- MetadataSource::InvalidSourceIndex,
338- selfTy);
339+ Sources.emplace_back (MetadataSource::Kind::SelfMetadata, selfTy);
339340
340341 if (selfTy->is <GenericTypeParamType>()) {
341342 // The Self type is abstract, so we can fulfill its metadata from
@@ -347,8 +348,7 @@ void PolymorphicConvention::considerWitnessSelf(CanSILFunctionType fnType) {
347348
348349 // The witness table for the Self : P conformance can be
349350 // fulfilled from the Self witness table parameter.
350- Sources.emplace_back (MetadataSource::Kind::SelfWitnessTable,
351- MetadataSource::InvalidSourceIndex, selfTy);
351+ Sources.emplace_back (MetadataSource::Kind::SelfWitnessTable, selfTy);
352352 addSelfWitnessTableFulfillment (selfTy, conformance);
353353}
354354
@@ -359,8 +359,7 @@ void PolymorphicConvention::considerObjCGenericSelf(CanSILFunctionType fnType) {
359359 unsigned paramIndex = fnType->getParameters ().size () - 1 ;
360360
361361 // Bind type metadata for Self.
362- Sources.emplace_back (MetadataSource::Kind::ClassPointer, paramIndex,
363- selfTy);
362+ Sources.emplace_back (MetadataSource::Kind::ClassPointer, selfTy, paramIndex);
364363
365364 if (isa<GenericTypeParamType>(selfTy))
366365 addSelfMetadataFulfillment (selfTy);
@@ -385,8 +384,9 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
385384 case ParameterConvention::Indirect_InoutAliasable:
386385 if (!isSelfParameter) return ;
387386 if (type->getNominalOrBoundGenericNominal ()) {
388- considerNewTypeSource (MetadataSource::Kind::GenericLValueMetadata,
389- paramIndex, type, IsExact);
387+ considerNewTypeSource (IsExact,
388+ MetadataSource::Kind::GenericLValueMetadata,
389+ type, paramIndex);
390390 }
391391 return ;
392392
@@ -395,15 +395,15 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
395395 case ParameterConvention::Direct_Guaranteed:
396396 // Classes are sources of metadata.
397397 if (type->getClassOrBoundGenericClass ()) {
398- considerNewTypeSource (MetadataSource::Kind::ClassPointer,
399- paramIndex, type, IsInexact );
398+ considerNewTypeSource (IsInexact, MetadataSource::Kind::ClassPointer,
399+ type, paramIndex );
400400 return ;
401401 }
402402
403403 if (isa<GenericTypeParamType>(type)) {
404404 if (auto superclassTy = getSuperclassBound (type)) {
405- considerNewTypeSource (MetadataSource::Kind::ClassPointer,
406- paramIndex, superclassTy, IsInexact );
405+ considerNewTypeSource (IsInexact, MetadataSource::Kind::ClassPointer,
406+ superclassTy, paramIndex );
407407 return ;
408408
409409 }
@@ -421,8 +421,8 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
421421 if (classDecl->isTypeErasedGenericClass ())
422422 return ;
423423
424- considerNewTypeSource (MetadataSource::Kind::Metadata,
425- paramIndex, objTy, IsInexact );
424+ considerNewTypeSource (IsInexact, MetadataSource::Kind::Metadata, objTy ,
425+ paramIndex);
426426 return ;
427427 }
428428
0 commit comments