@@ -38,21 +38,6 @@ using namespace Lowering;
3838
3939// MARK: utility functions
4040
41- // / Obtain a nominal type's member by name, as a VarDecl.
42- // / \returns nullptr if the name lookup doesn't resolve to exactly one member,
43- // / or the subsequent cast to VarDecl failed.
44- static VarDecl* lookupProperty (NominalTypeDecl *decl, DeclName name) {
45- assert (decl && " decl was null" );
46- if (auto clazz = dyn_cast<ClassDecl>(decl)) {
47- auto refs = decl->lookupDirect (name);
48- if (refs.size () != 1 )
49- return nullptr ;
50- return dyn_cast<VarDecl>(refs.front ());
51- }
52-
53- return nullptr ;
54- }
55-
5641// / Emit a reference to a specific stored property of the actor.
5742static SILValue emitActorPropertyReference (
5843 SILGenFunction &SGF, SILLocation loc, SILValue actorSelf,
@@ -186,7 +171,7 @@ static void emitActorSystemInit(SILGenFunction &SGF,
186171 // By construction, automatically generated distributed actor ctors have
187172 // exactly one ActorSystem-conforming argument to the constructor,
188173 // so we grab the first one from the params.
189- VarDecl *var = lookupProperty (classDecl, C.Id_actorSystem );
174+ VarDecl *var = lookupDistributedActorProperty (classDecl, C.Id_actorSystem );
190175 assert (var);
191176
192177 initializeProperty (SGF, loc, actorSelf.getValue (), var, systemValue);
@@ -219,7 +204,7 @@ void SILGenFunction::emitDistActorIdentityInit(ConstructorDecl *ctor,
219204
220205 // --- create a temporary storage for the result of the call
221206 // it will be deallocated automatically as we exit this scope
222- VarDecl *var = lookupProperty (classDecl, C.Id_id );
207+ VarDecl *var = lookupDistributedActorProperty (classDecl, C.Id_id );
223208 auto resultTy = getLoweredType (F.mapTypeIntoContext (var->getInterfaceType ()));
224209 auto temp = emitTemporaryAllocation (loc, resultTy);
225210
@@ -332,7 +317,7 @@ void SILGenFunction::emitDistributedActorReady(
332317 ManagedValue actorSystem;
333318 SGFContext sgfCxt;
334319 {
335- VarDecl *property = lookupProperty (classDecl, C.Id_actorSystem );
320+ VarDecl *property = lookupDistributedActorProperty (classDecl, C.Id_actorSystem );
336321 Type formalType = F.mapTypeIntoContext (property->getInterfaceType ());
337322 SILType loweredType = getLoweredType (formalType).getAddressType ();
338323 SILValue actorSystemRef = emitActorPropertyReference (
@@ -466,11 +451,11 @@ void SILGenFunction::emitDistributedActorFactory(FuncDecl *fd) { // TODO(distrib
466451 auto classDecl = dc->getSelfClassDecl ();
467452
468453 initializeProperty (*this , loc, remote,
469- lookupProperty (classDecl, C.Id_id ),
454+ lookupDistributedActorProperty (classDecl, C.Id_id ),
470455 idArg);
471456
472457 initializeProperty (*this , loc, remote,
473- lookupProperty (classDecl, C.Id_actorSystem ),
458+ lookupDistributedActorProperty (classDecl, C.Id_actorSystem ),
474459 actorSystemArg);
475460
476461 // ==== Branch to return the fully initialized remote instance
@@ -513,12 +498,12 @@ void SILGenFunction::emitDistributedActorSystemResignIDCall(
513498
514499 // ==== locate: self.id
515500 auto idRef = emitActorPropertyReference (
516- *this , loc, actorSelf.getValue (), lookupProperty (actorDecl, ctx.Id_id ));
501+ *this , loc, actorSelf.getValue (), lookupDistributedActorProperty (actorDecl, ctx.Id_id ));
517502
518503 // ==== locate: self.actorSystem
519504 auto systemRef = emitActorPropertyReference (
520505 *this , loc, actorSelf.getValue (),
521- lookupProperty (actorDecl, ctx.Id_actorSystem ));
506+ lookupDistributedActorProperty (actorDecl, ctx.Id_actorSystem ));
522507
523508 // Perform the call.
524509 emitDistributedActorSystemWitnessCall (
0 commit comments