@@ -1113,7 +1113,9 @@ emitConditionalConformancesBuffer(IRGenFunction &IGF,
1113
1113
for (auto idx : indices (tables)) {
1114
1114
auto slot =
1115
1115
IGF.Builder .CreateConstArrayGEP (buffer, idx, IGF.IGM .getPointerSize ());
1116
- IGF.Builder .CreateStore (tables[idx], slot);
1116
+ auto wtable =
1117
+ IGF.Builder .CreateBitCast (tables[idx], IGF.IGM .WitnessTablePtrTy );
1118
+ IGF.Builder .CreateStore (wtable, slot);
1117
1119
}
1118
1120
1119
1121
return buffer.getAddress ();
@@ -1184,15 +1186,11 @@ getWitnessTableLazyAccessFunction(IRGenModule &IGM,
1184
1186
return accessor;
1185
1187
}
1186
1188
1187
- static const ProtocolConformance &
1188
- mapConformanceIntoContext (IRGenModule &IGM, const RootProtocolConformance &conf,
1189
- DeclContext *dc) {
1190
- auto normal = dyn_cast<NormalProtocolConformance>(&conf);
1191
- if (!normal) return conf;
1192
- return *conf.subst ([&](SubstitutableType *t) -> Type {
1193
- return dc->mapTypeIntoContext (t);
1194
- },
1195
- LookUpConformanceInModule (IGM.getSwiftModule ()));
1189
+ static const ProtocolConformance *
1190
+ mapConformanceIntoContext (const RootProtocolConformance *conf) {
1191
+ if (auto *genericEnv = conf->getDeclContext ()->getGenericEnvironmentOfContext ())
1192
+ return conf->subst (genericEnv->getForwardingSubstitutionMap ());
1193
+ return conf;
1196
1194
}
1197
1195
1198
1196
WitnessIndex ProtocolInfo::getAssociatedTypeIndex (
@@ -1292,22 +1290,19 @@ class AccessorConformanceInfo : public ConformanceInfo {
1292
1290
protected:
1293
1291
IRGenModule &IGM;
1294
1292
SILWitnessTable *SILWT;
1295
- CanType ConcreteType;
1296
1293
const RootProtocolConformance &Conformance;
1297
1294
const ProtocolConformance &ConformanceInContext;
1295
+ CanType ConcreteType;
1298
1296
1299
1297
Optional<FulfillmentMap> Fulfillments;
1300
1298
1301
1299
WitnessTableBuilderBase (IRGenModule &IGM, SILWitnessTable *SILWT)
1302
1300
: IGM(IGM), SILWT(SILWT),
1303
- ConcreteType (SILWT->getConformance ()->getDeclContext()
1304
- ->mapTypeIntoContext(
1305
- SILWT->getConformance ()->getType())
1306
- ->getCanonicalType()),
1307
1301
Conformance (*SILWT->getConformance ()),
1308
- ConformanceInContext(
1309
- mapConformanceIntoContext (IGM, Conformance,
1310
- Conformance.getDeclContext())) {}
1302
+ ConformanceInContext(*mapConformanceIntoContext (SILWT->getConformance ())),
1303
+ ConcreteType(Conformance.getDeclContext()
1304
+ ->mapTypeIntoContext(Conformance.getType())
1305
+ ->getCanonicalType()) {}
1311
1306
1312
1307
void defineAssociatedTypeWitnessTableAccessFunction (
1313
1308
AssociatedConformance requirement,
0 commit comments