@@ -134,8 +134,10 @@ class PolymorphicConvention {
134
134
135
135
private:
136
136
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);
139
141
bool considerType (CanType type, IsExact_t isExact,
140
142
unsigned sourceIndex, MetadataPath &&path);
141
143
@@ -302,14 +304,15 @@ void PolymorphicConvention::initGenerics() {
302
304
Generics = FnType->getInvocationGenericSignature ();
303
305
}
304
306
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,
307
310
CanType type,
308
- IsExact_t isExact ) {
311
+ Args... args ) {
309
312
if (!Fulfillments.isInterestingTypeForFulfillments (type)) return ;
310
313
311
314
// Prospectively add a source.
312
- Sources.emplace_back (kind, paramIndex, type );
315
+ Sources.emplace_back (kind, type, std::forward<Args>(args)... );
313
316
314
317
// Consider the source.
315
318
if (!considerType (type, isExact, Sources.size () - 1 , MetadataPath ())) {
@@ -333,9 +336,7 @@ void PolymorphicConvention::considerWitnessSelf(CanSILFunctionType fnType) {
333
336
auto conformance = fnType->getWitnessMethodConformanceOrInvalid ();
334
337
335
338
// 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);
339
340
340
341
if (selfTy->is <GenericTypeParamType>()) {
341
342
// The Self type is abstract, so we can fulfill its metadata from
@@ -347,8 +348,7 @@ void PolymorphicConvention::considerWitnessSelf(CanSILFunctionType fnType) {
347
348
348
349
// The witness table for the Self : P conformance can be
349
350
// 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);
352
352
addSelfWitnessTableFulfillment (selfTy, conformance);
353
353
}
354
354
@@ -359,8 +359,7 @@ void PolymorphicConvention::considerObjCGenericSelf(CanSILFunctionType fnType) {
359
359
unsigned paramIndex = fnType->getParameters ().size () - 1 ;
360
360
361
361
// Bind type metadata for Self.
362
- Sources.emplace_back (MetadataSource::Kind::ClassPointer, paramIndex,
363
- selfTy);
362
+ Sources.emplace_back (MetadataSource::Kind::ClassPointer, selfTy, paramIndex);
364
363
365
364
if (isa<GenericTypeParamType>(selfTy))
366
365
addSelfMetadataFulfillment (selfTy);
@@ -385,8 +384,9 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
385
384
case ParameterConvention::Indirect_InoutAliasable:
386
385
if (!isSelfParameter) return ;
387
386
if (type->getNominalOrBoundGenericNominal ()) {
388
- considerNewTypeSource (MetadataSource::Kind::GenericLValueMetadata,
389
- paramIndex, type, IsExact);
387
+ considerNewTypeSource (IsExact,
388
+ MetadataSource::Kind::GenericLValueMetadata,
389
+ type, paramIndex);
390
390
}
391
391
return ;
392
392
@@ -395,15 +395,15 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
395
395
case ParameterConvention::Direct_Guaranteed:
396
396
// Classes are sources of metadata.
397
397
if (type->getClassOrBoundGenericClass ()) {
398
- considerNewTypeSource (MetadataSource::Kind::ClassPointer,
399
- paramIndex, type, IsInexact );
398
+ considerNewTypeSource (IsInexact, MetadataSource::Kind::ClassPointer,
399
+ type, paramIndex );
400
400
return ;
401
401
}
402
402
403
403
if (isa<GenericTypeParamType>(type)) {
404
404
if (auto superclassTy = getSuperclassBound (type)) {
405
- considerNewTypeSource (MetadataSource::Kind::ClassPointer,
406
- paramIndex, superclassTy, IsInexact );
405
+ considerNewTypeSource (IsInexact, MetadataSource::Kind::ClassPointer,
406
+ superclassTy, paramIndex );
407
407
return ;
408
408
409
409
}
@@ -421,8 +421,8 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
421
421
if (classDecl->isTypeErasedGenericClass ())
422
422
return ;
423
423
424
- considerNewTypeSource (MetadataSource::Kind::Metadata,
425
- paramIndex, objTy, IsInexact );
424
+ considerNewTypeSource (IsInexact, MetadataSource::Kind::Metadata, objTy ,
425
+ paramIndex);
426
426
return ;
427
427
}
428
428
0 commit comments