Skip to content

Commit 1f57572

Browse files
authored
Merge pull request #16879 from slavapestov/remove-bad-method-usage
SILGen: Remove a usage of the "bad" SubstitutionMap::get() variant
2 parents 5ab1a85 + d01b31e commit 1f57572

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4252,9 +4252,18 @@ RValue SILGenFunction::emitApply(ResultPlanPtr &&resultPlan,
42524252
// Emit the raw application.
42534253
auto genericSig =
42544254
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());
42584267
}
42594268

42604269
SILValue rawDirectResult = emitRawApply(

0 commit comments

Comments
 (0)