@@ -55,7 +55,7 @@ static VarDecl *addImplicitDistributedActorIDProperty(
55
55
// ==== Synthesize and add 'id' property to the actor decl
56
56
Type propertyType = getDistributedActorIDType (nominal);
57
57
58
- VarDecl *propDecl = new (C)
58
+ auto *propDecl = new (C)
59
59
VarDecl (/* IsStatic*/ false , VarDecl::Introducer::Let,
60
60
SourceLoc (), C.Id_id , nominal);
61
61
propDecl->setImplicit ();
@@ -230,20 +230,21 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
230
230
231
231
// --- Recording invocation details
232
232
// -- recordGenericSubstitution(s)
233
- if (func ->isGeneric () || nominal->isGeneric ()) {
233
+ if (thunk ->isGeneric () || nominal->isGeneric ()) {
234
234
auto recordGenericSubstitutionDecl =
235
235
C.getRecordGenericSubstitutionOnDistributedInvocationEncoder (invocationEncoderDecl);
236
236
assert (recordGenericSubstitutionDecl);
237
237
auto recordGenericSubstitutionDeclRef =
238
238
UnresolvedDeclRefExpr::createImplicit (
239
239
C, recordGenericSubstitutionDecl->getName ());
240
240
241
- auto sig = func ->getGenericSignature ();
242
- for (auto genParamType : sig .getGenericParams ()) {
241
+ auto signature = thunk ->getGenericSignature ();
242
+ for (auto genParamType : signature .getGenericParams ()) {
243
243
244
+ auto tyExpr = TypeExpr::createImplicit (thunk->mapTypeIntoContext (genParamType), C);
244
245
auto subTypeExpr = new (C) DotSelfExpr (
245
- TypeExpr::createImplicit (thunk-> mapTypeIntoContext (genParamType), C) ,
246
- sloc, sloc, thunk-> mapTypeIntoContext (genParamType ));
246
+ tyExpr ,
247
+ sloc, sloc, tyExpr-> getType ( ));
247
248
248
249
auto recordGenericSubArgsList =
249
250
ArgumentList::forImplicitCallTo (
@@ -378,7 +379,8 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
378
379
// -- recordReturnType
379
380
if (!isVoidReturn) {
380
381
// Result.self
381
- auto resultType = func->getResultInterfaceType ();
382
+ // Watch out and always map into thunk context
383
+ auto resultType = thunk->mapTypeIntoContext (func->getResultInterfaceType ());
382
384
auto *metaTypeRef = TypeExpr::createImplicit (resultType, C);
383
385
auto *resultTypeExpr =
384
386
new (C) DotSelfExpr (metaTypeRef, sloc, sloc, resultType);
@@ -426,9 +428,8 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
426
428
}
427
429
428
430
// === Prepare the 'RemoteCallTarget'
429
- VarDecl *targetVar =
430
- new (C) VarDecl (/* isStatic=*/ false , VarDecl::Introducer::Let, sloc,
431
- C.Id_target , thunk);
431
+ auto *targetVar = new (C) VarDecl (
432
+ /* isStatic=*/ false , VarDecl::Introducer::Let, sloc, C.Id_target , thunk);
432
433
433
434
{
434
435
// --- Mangle the thunk name
@@ -510,7 +511,8 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
510
511
// -- returning: Res.Type
511
512
if (!isVoidReturn) {
512
513
// Result.self
513
- auto resultType = func->getResultInterfaceType ();
514
+ auto resultType =
515
+ func->mapTypeIntoContext (func->getResultInterfaceType ());
514
516
auto *metaTypeRef = TypeExpr::createImplicit (resultType, C);
515
517
auto *resultTypeExpr =
516
518
new (C) DotSelfExpr (metaTypeRef, sloc, sloc, resultType);
@@ -561,7 +563,7 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
561
563
genericParamList = genericParams->clone (DC);
562
564
}
563
565
564
- GenericSignature thunkGenSig =
566
+ GenericSignature baseSignature =
565
567
buildGenericSignature (C, func->getGenericSignature (),
566
568
/* addedParameters=*/ {},
567
569
/* addedRequirements=*/ {});
@@ -581,9 +583,9 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
581
583
}
582
584
583
585
auto paramDecl = new (C)
584
- ParamDecl (SourceLoc (),
585
- /* argumentNameLoc=*/ SourceLoc (), funcParam->getArgumentName (),
586
- /* parameterNameLoc=*/ SourceLoc (), paramName, DC);
586
+ ParamDecl (SourceLoc (),
587
+ /* argumentNameLoc=*/ SourceLoc (), funcParam->getArgumentName (),
588
+ /* parameterNameLoc=*/ SourceLoc (), paramName, DC);
587
589
588
590
paramDecl->setImplicit (true );
589
591
paramDecl->setSpecifier (funcParam->getSpecifier ());
@@ -593,16 +595,14 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
593
595
}
594
596
ParameterList *params = ParameterList::create (C, paramDecls); // = funcParams->clone(C);
595
597
596
- auto thunk = FuncDecl::createImplicit (C, swift::StaticSpellingKind::None,
597
- thunkName, SourceLoc (),
598
- /* async=*/ true , /* throws=*/ true ,
599
- genericParamList,
600
- params,
601
- func->getResultInterfaceType (),
602
- DC);
598
+ auto thunk = FuncDecl::createImplicit (
599
+ C, swift::StaticSpellingKind::None, thunkName, SourceLoc (),
600
+ /* async=*/ true , /* throws=*/ true ,
601
+ genericParamList, params,
602
+ func->getResultInterfaceType (), DC);
603
603
thunk->setSynthesized (true );
604
- thunk->getAttrs ().add (new (C) NonisolatedAttr (/* implicit =*/ true ));
605
- thunk->setGenericSignature (thunkGenSig );
604
+ thunk->getAttrs ().add (new (C) NonisolatedAttr (/* isImplicit =*/ true ));
605
+ thunk->setGenericSignature (baseSignature );
606
606
thunk->copyFormalAccessFrom (func, /* sourceIsParentContext=*/ false );
607
607
thunk->setBodySynthesizer (deriveBodyDistributed_thunk, func);
608
608
0 commit comments