@@ -1222,23 +1222,11 @@ SILInstruction *SILCombiner::createApplyWithConcreteType(
1222
1222
NewArgs.push_back (cast);
1223
1223
// Form a new set of substitutions where the argument is
1224
1224
// replaced with a concrete type.
1225
- NewCallSubs = NewCallSubs.subst (
1226
- [&](SubstitutableType *type) -> Type {
1227
- if (type == OAI.OpenedArchetype )
1228
- return CEI.ConcreteType ;
1229
- return type;
1230
- },
1231
- [&](CanType origTy, Type substTy,
1232
- ProtocolDecl *proto) -> ProtocolConformanceRef {
1233
- if (origTy->isEqual (OAI.OpenedArchetype )) {
1234
- assert (substTy->isEqual (CEI.ConcreteType ));
1235
- // Do a conformance lookup on this witness requirement using the
1236
- // existential's conformances. The witness requirement may be a
1237
- // base type of the existential's requirements.
1238
- return CEI.lookupExistentialConformance (proto);
1239
- }
1240
- return ProtocolConformanceRef::forAbstract (substTy, proto);
1241
- }, SubstFlags::SubstituteLocalArchetypes);
1225
+ ReplaceExistentialArchetypesWithConcreteTypes replacer (
1226
+ OAI.OpenedArchetype ->getGenericEnvironment (),
1227
+ CEI.ExistentialSubs );
1228
+ NewCallSubs = NewCallSubs.subst (replacer, replacer,
1229
+ SubstFlags::SubstituteLocalArchetypes);
1242
1230
continue ;
1243
1231
}
1244
1232
// Otherwise, use the original argument.
@@ -1263,23 +1251,11 @@ SILInstruction *SILCombiner::createApplyWithConcreteType(
1263
1251
1264
1252
// Form a new set of substitutions where the argument is
1265
1253
// replaced with a concrete type.
1266
- NewCallSubs = NewCallSubs.subst (
1267
- [&](SubstitutableType *type) -> Type {
1268
- if (type == OAI.OpenedArchetype )
1269
- return CEI.ConcreteType ;
1270
- return type;
1271
- },
1272
- [&](CanType origTy, Type substTy,
1273
- ProtocolDecl *proto) -> ProtocolConformanceRef {
1274
- if (origTy->isEqual (OAI.OpenedArchetype )) {
1275
- assert (substTy->isEqual (CEI.ConcreteType ));
1276
- // Do a conformance lookup on this witness requirement using the
1277
- // existential's conformances. The witness requirement may be a
1278
- // base type of the existential's requirements.
1279
- return CEI.lookupExistentialConformance (proto);
1280
- }
1281
- return ProtocolConformanceRef::forAbstract (substTy, proto);
1282
- }, SubstFlags::SubstituteLocalArchetypes);
1254
+ ReplaceExistentialArchetypesWithConcreteTypes replacer (
1255
+ OAI.OpenedArchetype ->getGenericEnvironment (),
1256
+ CEI.ExistentialSubs );
1257
+ NewCallSubs = NewCallSubs.subst (replacer, replacer,
1258
+ SubstFlags::SubstituteLocalArchetypes);
1283
1259
}
1284
1260
1285
1261
// We need to make sure that we can a) update Apply to use the new args and b)
0 commit comments