@@ -3664,22 +3664,22 @@ llvm::Value *irgen::emitTaskCreate(
3664
3664
// Determine the size of the async context for the closure.
3665
3665
ASTContext &ctx = IGF.IGM .IRGen .SIL .getASTContext ();
3666
3666
auto extInfo = ASTExtInfoBuilder ().withAsync ().withThrows ().build ();
3667
- AnyFunctionType *taskFunctionType;
3667
+ CanSILFunctionType taskFunctionType;
3668
+ CanSILFunctionType substTaskFunctionType;
3668
3669
if (futureResultType) {
3669
3670
auto genericParam = GenericTypeParamType::get (0 , 0 , ctx);
3670
3671
auto genericSig = GenericSignature::get ({genericParam}, {});
3671
- taskFunctionType = GenericFunctionType::get (
3672
- genericSig, { }, genericParam, extInfo);
3672
+ auto *ty = GenericFunctionType::get (genericSig, { }, genericParam, extInfo);
3673
3673
3674
- taskFunctionType = Type (taskFunctionType).subst (subs)->castTo <FunctionType>();
3674
+ taskFunctionType = IGF.IGM .getLoweredType (ty).castTo <SILFunctionType>();
3675
+ substTaskFunctionType = taskFunctionType->withInvocationSubstitutions (subs);
3675
3676
} 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;
3678
3680
}
3679
- CanSILFunctionType taskFunctionCanSILType =
3680
- IGF.IGM .getLoweredType (taskFunctionType).castTo <SILFunctionType>();
3681
3681
auto layout = getAsyncContextLayout (
3682
- IGF.IGM , taskFunctionCanSILType, taskFunctionCanSILType , subs);
3682
+ IGF.IGM , taskFunctionType, substTaskFunctionType , subs);
3683
3683
3684
3684
CanSILFunctionType taskContinuationFunctionTy = [&]() {
3685
3685
ASTContext &ctx = IGF.IGM .IRGen .SIL .getASTContext ();
@@ -3700,7 +3700,7 @@ llvm::Value *irgen::emitTaskCreate(
3700
3700
llvm::CallInst *result;
3701
3701
llvm::Value *theSize, *theFunction;
3702
3702
auto taskFunctionPointer = FunctionPointer::forExplosionValue (
3703
- IGF, taskFunction, taskFunctionCanSILType );
3703
+ IGF, taskFunction, substTaskFunctionType );
3704
3704
std::tie (theFunction, theSize) =
3705
3705
getAsyncFunctionAndSize (IGF, SILFunctionTypeRepresentation::Thick,
3706
3706
taskFunctionPointer, localContextInfo);
0 commit comments