Skip to content

Commit fd5cd89

Browse files
[wasm] tentative fix for DiscardingTaskGroup's ABI signature mismatch
swiftlang#63060
1 parent 135e2f7 commit fd5cd89

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,8 +1605,33 @@ static ManagedValue emitBuiltinCreateAsyncTaskInGroup(
16051605
SGF.B.createMetatype(loc, SGF.getLoweredType(futureResultType)));
16061606
}).borrow(SGF, loc).forward(SGF);
16071607

1608-
auto function = emitFunctionArgumentForAsyncTaskEntryPoint(SGF, loc, args[2],
1609-
futureResultType);
1608+
// FIXME(katei): This is a hack to fix the ABI signature mismatch issue
1609+
// https://github.com/apple/swift/issues/63060
1610+
// ==================== BEGIN HACK ====================
1611+
// Ensure that the closure has the appropriate type.
1612+
auto extInfo =
1613+
ASTExtInfoBuilder()
1614+
.withAsync()
1615+
.withThrows()
1616+
.withRepresentation(GenericFunctionType::Representation::Swift)
1617+
.build();
1618+
auto genericSig = subs.getGenericSignature().getCanonicalSignature();
1619+
auto genericResult =
1620+
GenericTypeParamType::get(/*isParameterPack*/ false,
1621+
/*depth*/ 0, /*index*/ 0, SGF.getASTContext());
1622+
// <T> () async throws -> Void
1623+
CanType functionTy =
1624+
GenericFunctionType::get(genericSig, {}, genericResult, extInfo)
1625+
->getCanonicalType();
1626+
AbstractionPattern origParam(genericSig, functionTy);
1627+
CanType substParamType = functionTy.subst(subs)->getCanonicalType();
1628+
auto reabstractedFun =
1629+
SGF.emitSubstToOrigValue(loc, args[2], origParam, substParamType);
1630+
// ==================== END HACK ======================
1631+
1632+
auto function = emitFunctionArgumentForAsyncTaskEntryPoint(
1633+
SGF, loc, reabstractedFun, futureResultType);
1634+
16101635
auto apply = SGF.B.createBuiltin(
16111636
loc,
16121637
ctx.getIdentifier(

0 commit comments

Comments
 (0)