@@ -356,6 +356,12 @@ expandTupleTypes(AnyFunctionType::CanParamArrayRef params) {
356356 return results;
357357}
358358
359+ static CanAnyFunctionType getBridgedBlockType (SILGenModule &SGM,
360+ CanAnyFunctionType blockType) {
361+ return SGM.Types .getBridgedFunctionType (AbstractionPattern (blockType),
362+ blockType, blockType->getExtInfo ());
363+ }
364+
359365static void buildFuncToBlockInvokeBody (SILGenFunction &SGF,
360366 SILLocation loc,
361367 CanAnyFunctionType formalFuncType,
@@ -369,10 +375,7 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
369375 SILFunctionConventions funcConv (funcTy, SGF.SGM .M );
370376
371377 // Make sure we lower the component types of the formal block type.
372- formalBlockType =
373- SGF.SGM .Types .getBridgedFunctionType (AbstractionPattern (formalBlockType),
374- formalBlockType,
375- formalBlockType->getExtInfo ());
378+ formalBlockType = getBridgedBlockType (SGF.SGM , formalBlockType);
376379
377380 // Set up the indirect result.
378381 SILType blockResultTy = blockTy->getAllResultsType ();
@@ -762,6 +765,9 @@ static void buildBlockToFuncThunkBody(SILGenFunction &SGF,
762765 // Collect the native arguments, which should all be +1.
763766 Scope scope (SGF.Cleanups , CleanupLocation::get (loc));
764767
768+ // Make sure we lower the component types of the formal block type.
769+ formalBlockTy = getBridgedBlockType (SGF.SGM , formalBlockTy);
770+
765771 assert (blockTy->getNumParameters () == funcTy->getNumParameters ()
766772 && " block and function types don't match" );
767773
0 commit comments