@@ -1222,23 +1222,11 @@ SILInstruction *SILCombiner::createApplyWithConcreteType(
12221222 NewArgs.push_back (cast);
12231223 // Form a new set of substitutions where the argument is
12241224 // 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);
12421230 continue ;
12431231 }
12441232 // Otherwise, use the original argument.
@@ -1263,23 +1251,11 @@ SILInstruction *SILCombiner::createApplyWithConcreteType(
12631251
12641252 // Form a new set of substitutions where the argument is
12651253 // 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);
12831259 }
12841260
12851261 // We need to make sure that we can a) update Apply to use the new args and b)
0 commit comments