File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -4252,9 +4252,18 @@ RValue SILGenFunction::emitApply(ResultPlanPtr &&resultPlan,
4252
4252
// Emit the raw application.
4253
4253
auto genericSig =
4254
4254
fn.getType ().castTo <SILFunctionType>()->getGenericSignature ();
4255
- if (genericSig != subs.getGenericSignature ()) {
4256
- // FIXME: This should not happen
4257
- subs = SubstitutionMap::get (genericSig, subs);
4255
+
4256
+ // When calling a closure that's defined in a generic context but does not
4257
+ // capture any generic parameters, we will have substitutions, but the
4258
+ // function type won't have a generic signature. Drop the substitutions in
4259
+ // this case.
4260
+ if (genericSig == nullptr ) {
4261
+ subs = SubstitutionMap ();
4262
+
4263
+ // Otherwise, the substitutions should match the generic signature.
4264
+ } else {
4265
+ assert (genericSig->getCanonicalSignature () ==
4266
+ subs.getGenericSignature ()->getCanonicalSignature ());
4258
4267
}
4259
4268
4260
4269
SILValue rawDirectResult = emitRawApply (
You can’t perform that action at this time.
0 commit comments