@@ -355,6 +355,12 @@ expandTupleTypes(AnyFunctionType::CanParamArrayRef params) {
355355 return results;
356356}
357357
358+ static CanAnyFunctionType getBridgedBlockType (SILGenModule &SGM,
359+ CanAnyFunctionType blockType) {
360+ return SGM.Types .getBridgedFunctionType (AbstractionPattern (blockType),
361+ blockType, blockType->getExtInfo ());
362+ }
363+
358364static void buildFuncToBlockInvokeBody (SILGenFunction &SGF,
359365 SILLocation loc,
360366 CanAnyFunctionType formalFuncType,
@@ -368,10 +374,7 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
368374 SILFunctionConventions funcConv (funcTy, SGF.SGM .M );
369375
370376 // Make sure we lower the component types of the formal block type.
371- formalBlockType =
372- SGF.SGM .Types .getBridgedFunctionType (AbstractionPattern (formalBlockType),
373- formalBlockType,
374- formalBlockType->getExtInfo ());
377+ formalBlockType = getBridgedBlockType (SGF.SGM , formalBlockType);
375378
376379 // Set up the indirect result.
377380 SILType blockResultTy = blockTy->getAllResultsType ();
@@ -764,6 +767,9 @@ static void buildBlockToFuncThunkBody(SILGenFunction &SGF,
764767 // Collect the native arguments, which should all be +1.
765768 Scope scope (SGF.Cleanups , CleanupLocation::get (loc));
766769
770+ // Make sure we lower the component types of the formal block type.
771+ formalBlockTy = getBridgedBlockType (SGF.SGM , formalBlockTy);
772+
767773 assert (blockTy->getNumParameters () == funcTy->getNumParameters ()
768774 && " block and function types don't match" );
769775
0 commit comments