Skip to content

Commit 7bc012a

Browse files
committed
[sil-generic-specializer] Set a generic context a bit earlier so that all functions using type-lowering can use it.
Fixes rdar://31838976 (SR-4704)
1 parent 30a50f9 commit 7bc012a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,11 @@ SILFunction *ReabstractionThunkGenerator::createThunk() {
18891889

18901890
Thunk->setGenericEnvironment(ReInfo.getSpecializedGenericEnvironment());
18911891

1892+
// Set proper generic context scope for the type lowering.
1893+
CanSILFunctionType SpecType = SpecializedFunc->getLoweredFunctionType();
1894+
Lowering::GenericContextScope GenericScope(M.Types,
1895+
SpecType->getGenericSignature());
1896+
18921897
SILBasicBlock *EntryBB = Thunk->createBasicBlock();
18931898
SILBuilder Builder(EntryBB);
18941899

@@ -1980,9 +1985,6 @@ SILArgument *ReabstractionThunkGenerator::convertReabstractionThunkArguments(
19801985

19811986
assert(specConv.useLoweredAddresses());
19821987

1983-
Lowering::GenericContextScope GenericScope(M.Types,
1984-
SpecType->getGenericSignature());
1985-
19861988
// ReInfo.NumIndirectResults corresponds to SubstTy's formal indirect
19871989
// results. SpecTy may have fewer formal indirect results.
19881990
assert(SubstType->getNumIndirectFormalResults()

0 commit comments

Comments
 (0)