@@ -341,6 +341,11 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
341341 blockInterfaceTy->getParameters ().end (),
342342 std::back_inserter (params));
343343
344+ auto genericSig = F.getLoweredFunctionType ()->getGenericSignature ();
345+ auto extInfo =
346+ SILFunctionType::ExtInfo ()
347+ .withRepresentation (SILFunctionType::Representation::CFunctionPointer);
348+
344349 // The block invoke function must be pseudogeneric. This should be OK for now
345350 // since a bridgeable function's parameters and returns should all be
346351 // trivially representable in ObjC so not need to exercise the type metadata.
@@ -349,17 +354,17 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
349354 // that will require a redesign of the interface to support dependent-layout
350355 // context. Currently we don't capture anything directly into a block but a
351356 // Swift closure, but that's totally dumb.
357+ if (genericSig)
358+ extInfo = extInfo.withIsPseudogeneric ();
359+
352360 auto invokeTy =
353- SILFunctionType::get (F.getLoweredFunctionType ()->getGenericSignature (),
354- SILFunctionType::ExtInfo ()
355- .withRepresentation (SILFunctionType::Representation::
356- CFunctionPointer)
357- .withIsPseudogeneric (),
358- ParameterConvention::Direct_Unowned,
359- params,
360- blockInterfaceTy->getAllResults (),
361- blockInterfaceTy->getOptionalErrorResult (),
362- getASTContext ());
361+ SILFunctionType::get (genericSig,
362+ extInfo,
363+ ParameterConvention::Direct_Unowned,
364+ params,
365+ blockInterfaceTy->getAllResults (),
366+ blockInterfaceTy->getOptionalErrorResult (),
367+ getASTContext ());
363368
364369 // Create the invoke function. Borrow the mangling scheme from reabstraction
365370 // thunks, which is what we are in spirit.
0 commit comments