@@ -995,6 +995,10 @@ getWitnessTableLazyAccessFunction(IRGenModule &IGM,
995
995
return accessor;
996
996
}
997
997
998
+ static void bindArchetypeAccessPaths (IRGenFunction &IGF,
999
+ GenericSignature *Generics,
1000
+ GetTypeParameterInContextFn getInContext);
1001
+
998
1002
namespace {
999
1003
1000
1004
// / Conformance info for a witness table that can be directly generated.
@@ -1276,6 +1280,17 @@ class AccessorConformanceInfo : public ConformanceInfo {
1276
1280
}
1277
1281
return *Fulfillments;
1278
1282
}
1283
+
1284
+ void bindArchetypeAccessPathsInConformance (IRGenFunction &IGF) {
1285
+ auto declCtx = Conformance.getDeclContext ();
1286
+ if (auto generics = declCtx->getGenericSignatureOfContext ()) {
1287
+ auto getInContext = [&](CanType type) -> CanType {
1288
+ return ArchetypeBuilder::mapTypeIntoContext (declCtx, type, nullptr )
1289
+ ->getCanonicalType ();
1290
+ };
1291
+ bindArchetypeAccessPaths (IGF, generics, getInContext);
1292
+ }
1293
+ }
1279
1294
};
1280
1295
}
1281
1296
@@ -1335,6 +1350,9 @@ getAssociatedTypeMetadataAccessFunction(AssociatedTypeDecl *requirement,
1335
1350
// Bind local type data from the metadata argument.
1336
1351
IGF.bindLocalTypeDataFromTypeMetadata (ConcreteType, IsExact, self);
1337
1352
1353
+ // Bind archetype access paths.
1354
+ bindArchetypeAccessPathsInConformance (IGF);
1355
+
1338
1356
// For now, assume that an associated type is cheap enough to access
1339
1357
// that it doesn't need a new cache entry.
1340
1358
if (auto archetype = dyn_cast<ArchetypeType>(associatedType)) {
@@ -1458,6 +1476,9 @@ getAssociatedTypeWitnessTableAccessFunction(AssociatedTypeDecl *requirement,
1458
1476
associatedTypeMetadata);
1459
1477
IGF.bindLocalTypeDataFromTypeMetadata (ConcreteType, IsExact, self);
1460
1478
1479
+ // Bind archetype access paths.
1480
+ bindArchetypeAccessPathsInConformance (IGF);
1481
+
1461
1482
// For now, assume that finding an abstract conformance is always
1462
1483
// fast enough that it's not worth caching.
1463
1484
// TODO: provide an API to find the best metadata path to the conformance
0 commit comments