32
32
using namespace swift ;
33
33
34
34
35
- /* *****************************************************************************/
36
- /* ***************************** UTILS *****************************************/
37
- /* *****************************************************************************/
38
-
39
- static DeclName createDistributedFuncName (ASTContext &C, FuncDecl* func) {
40
- // std::string localFuncNameString = "$dist_";
41
- std::string localFuncNameString = " " ;
42
- localFuncNameString.append (std::string (func->getBaseName ().getIdentifier ().str ()));
43
- auto thunkBaseName = DeclBaseName (C.getIdentifier (StringRef (localFuncNameString)));
44
- return DeclName (C, thunkBaseName, func->getParameters ());
45
- }
46
-
47
35
/* *****************************************************************************/
48
36
/* *********************** PROPERTY SYNTHESIS **********************************/
49
37
/* *****************************************************************************/
@@ -106,7 +94,7 @@ static void forwardParameters(AbstractFunctionDecl *afd,
106
94
forwardingParams.push_back (new (C) DeclRefExpr (
107
95
ConcreteDeclRef (param), DeclNameLoc (), /* implicit=*/ true ,
108
96
swift::AccessSemantics::Ordinary,
109
- param->getInterfaceType ()));
97
+ afd-> mapTypeIntoContext ( param->getInterfaceType () )));
110
98
}
111
99
}
112
100
@@ -145,7 +133,6 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
145
133
assert (systemConfRef && " ActorSystem must conform to DistributedActorSystem" );
146
134
147
135
// === ActorSystem.InvocationEncoder
148
- ProtocolDecl *DTIE = C.getDistributedTargetInvocationEncoderDecl ();
149
136
Type invocationEncoderTy =
150
137
getDistributedActorSystemInvocationEncoderType (systemDecl);
151
138
NominalTypeDecl *invocationEncoderDecl = invocationEncoderTy->getAnyNominal ();
@@ -195,7 +182,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
195
182
196
183
auto *systemVar =
197
184
new (C) VarDecl (/* isStatic=*/ false , VarDecl::Introducer::Let, sloc,
198
- C.getIdentifier ( " system " ) , thunk);
185
+ C.Id_system , thunk);
199
186
systemVar->setInterfaceType (systemProperty->getInterfaceType ());
200
187
systemVar->setImplicit ();
201
188
systemVar->setSynthesized ();
@@ -212,7 +199,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
212
199
// --- invocationEncoder = system.makeInvocationEncoder()
213
200
auto *invocationVar =
214
201
new (C) VarDecl (/* isStatic=*/ false , VarDecl::Introducer::Var, sloc,
215
- C.getIdentifier ( " invocation " ) , thunk);
202
+ C.Id_invocation , thunk);
216
203
invocationVar->setInterfaceType (invocationEncoderTy);
217
204
invocationVar->setImplicit ();
218
205
invocationVar->setSynthesized ();
@@ -228,7 +215,6 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
228
215
auto *makeInvocationArgs = ArgumentList::createImplicit (C, {});
229
216
auto makeInvocationCallExpr =
230
217
CallExpr::createImplicit (C, makeInvocationExpr, makeInvocationArgs);
231
- makeInvocationCallExpr->setType (DTIE->getInterfaceType ());
232
218
makeInvocationCallExpr->setThrows (false );
233
219
234
220
auto invocationEncoderPB = PatternBindingDecl::createImplicit (
@@ -384,7 +370,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
384
370
// === Prepare the 'RemoteCallTarget'
385
371
VarDecl *targetVar =
386
372
new (C) VarDecl (/* isStatic=*/ false , VarDecl::Introducer::Let, sloc,
387
- C.getIdentifier ( " target " ) , thunk);
373
+ C.Id_target , thunk);
388
374
389
375
{
390
376
// --- Mangle the thunk name
@@ -510,7 +496,7 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
510
496
assert (systemTy &&
511
497
" Thunk synthesis must have concrete actor system type available" );
512
498
513
- DeclName thunkName = createDistributedFuncName (C, func);
499
+ DeclName thunkName = func-> getName ( );
514
500
515
501
// --- Prepare generic parameters
516
502
GenericParamList *genericParamList = nullptr ;
@@ -571,14 +557,14 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
571
557
/* *****************************************************************************/
572
558
573
559
FuncDecl *GetDistributedThunkRequest::evaluate (
574
- Evaluator &evaluator, AbstractFunctionDecl *afd ) const {
575
- if (!afd ->isDistributed ())
560
+ Evaluator &evaluator, AbstractFunctionDecl *distributedTarget ) const {
561
+ if (!distributedTarget ->isDistributed ())
576
562
return nullptr ;
577
563
578
- auto &C = afd ->getASTContext ();
579
- auto DC = afd ->getDeclContext ();
564
+ auto &C = distributedTarget ->getASTContext ();
565
+ auto DC = distributedTarget ->getDeclContext ();
580
566
581
- if (!getConcreteReplacementForProtocolActorSystemType (afd )) {
567
+ if (!getConcreteReplacementForProtocolActorSystemType (distributedTarget )) {
582
568
// Don't synthesize thunks, unless there is a *concrete* ActorSystem.
583
569
// TODO(distributed): we should be able to lift this eventually,
584
570
// and allow resolving distributed actor protocols.
@@ -588,12 +574,12 @@ FuncDecl *GetDistributedThunkRequest::evaluate(
588
574
// Force type-checking the original function, so we can avoid synthesizing
589
575
// the thunks (which would have many of the same errors, if they are caused
590
576
// by a bad source function signature, e.g. missing conformances etc).
591
- (void ) TypeChecker::typeCheckDecl (afd );
592
- if (afd ->getDiags ().hadAnyError ()) {
577
+ (void ) TypeChecker::typeCheckDecl (distributedTarget );
578
+ if (distributedTarget ->getDiags ().hadAnyError ()) {
593
579
return nullptr ;
594
580
}
595
581
596
- if (auto func = dyn_cast<FuncDecl>(afd )) {
582
+ if (auto func = dyn_cast<FuncDecl>(distributedTarget )) {
597
583
// not via `ensureDistributedModuleLoaded` to avoid generating a warning,
598
584
// we won't be emitting the offending decl after all.
599
585
if (!C.getLoadedModule (C.Id_Distributed ))
0 commit comments