@@ -3664,22 +3664,22 @@ llvm::Value *irgen::emitTaskCreate(
36643664 // Determine the size of the async context for the closure.
36653665 ASTContext &ctx = IGF.IGM .IRGen .SIL .getASTContext ();
36663666 auto extInfo = ASTExtInfoBuilder ().withAsync ().withThrows ().build ();
3667- AnyFunctionType *taskFunctionType;
3667+ CanSILFunctionType taskFunctionType;
3668+ CanSILFunctionType substTaskFunctionType;
36683669 if (futureResultType) {
36693670 auto genericParam = GenericTypeParamType::get (0 , 0 , ctx);
36703671 auto genericSig = GenericSignature::get ({genericParam}, {});
3671- taskFunctionType = GenericFunctionType::get (
3672- genericSig, { }, genericParam, extInfo);
3672+ auto *ty = GenericFunctionType::get (genericSig, { }, genericParam, extInfo);
36733673
3674- taskFunctionType = Type (taskFunctionType).subst (subs)->castTo <FunctionType>();
3674+ taskFunctionType = IGF.IGM .getLoweredType (ty).castTo <SILFunctionType>();
3675+ substTaskFunctionType = taskFunctionType->withInvocationSubstitutions (subs);
36753676 } else {
3676- taskFunctionType = FunctionType::get (
3677- { }, ctx.TheEmptyTupleType , extInfo);
3677+ auto *ty = FunctionType::get ({ }, ctx.TheEmptyTupleType , extInfo);
3678+ taskFunctionType = IGF.IGM .getLoweredType (ty).castTo <SILFunctionType>();
3679+ substTaskFunctionType = taskFunctionType;
36783680 }
3679- CanSILFunctionType taskFunctionCanSILType =
3680- IGF.IGM .getLoweredType (taskFunctionType).castTo <SILFunctionType>();
36813681 auto layout = getAsyncContextLayout (
3682- IGF.IGM , taskFunctionCanSILType, taskFunctionCanSILType , subs);
3682+ IGF.IGM , taskFunctionType, substTaskFunctionType , subs);
36833683
36843684 CanSILFunctionType taskContinuationFunctionTy = [&]() {
36853685 ASTContext &ctx = IGF.IGM .IRGen .SIL .getASTContext ();
@@ -3700,7 +3700,7 @@ llvm::Value *irgen::emitTaskCreate(
37003700 llvm::CallInst *result;
37013701 llvm::Value *theSize, *theFunction;
37023702 auto taskFunctionPointer = FunctionPointer::forExplosionValue (
3703- IGF, taskFunction, taskFunctionCanSILType );
3703+ IGF, taskFunction, substTaskFunctionType );
37043704 std::tie (theFunction, theSize) =
37053705 getAsyncFunctionAndSize (IGF, SILFunctionTypeRepresentation::Thick,
37063706 taskFunctionPointer, localContextInfo);
0 commit comments