Skip to content

Commit b455ac4

Browse files
committed
Fix use of SILTypeSubstituter and TypeSubstitutionFn
1 parent 36f25ee commit b455ac4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,11 +3769,18 @@ SILType SILType::subst(SILModule &M, SubstitutionMap subs,
37693769
if (!hasArchetype() && !hasTypeParameter() &&
37703770
!getASTType()->hasOpaqueArchetype())
37713771
return *this;
3772-
SILTypeSubstituter STST(M.Types, context, QuerySubstitutionMap{subs},
3773-
LookUpConformanceInSubstitutionMap(subs),
3774-
subs.getGenericSignature().getCanonicalSignature(),
3775-
false);
3776-
return STST.subst(*this);
3772+
3773+
// Pass the TypeSubstitutionFn and LookupConformanceFn as arguments so that
3774+
// the llvm::function_ref value's scope spans the STST.subst call since
3775+
// SILTypeSubstituter captures these functions.
3776+
auto result = [&](TypeSubstitutionFn subsFn,
3777+
LookupConformanceFn conformancesFn) -> SILType {
3778+
SILTypeSubstituter STST(M.Types, context, subsFn, conformancesFn,
3779+
subs.getGenericSignature().getCanonicalSignature(),
3780+
false);
3781+
return STST.subst(*this);
3782+
}(QuerySubstitutionMap{subs}, LookUpConformanceInSubstitutionMap(subs));
3783+
return result;
37773784
}
37783785

37793786
/// Apply a substitution to this polymorphic SILFunctionType so that

0 commit comments

Comments
 (0)