File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ class ActorIsolation {
192192 }
193193
194194 NominalTypeDecl *getActor () const ;
195+ NominalTypeDecl *getActorOrNullPtr () const ;
195196
196197 VarDecl *getActorInstance () const ;
197198
Original file line number Diff line number Diff line change @@ -11348,6 +11348,31 @@ NominalTypeDecl *ActorIsolation::getActor() const {
1134811348 return actorInstance.get <NominalTypeDecl *>();
1134911349}
1135011350
11351+ NominalTypeDecl *ActorIsolation::getActorOrNullPtr () const {
11352+ if (getKind () != ActorInstance || getKind () != GlobalActor)
11353+ return nullptr ;
11354+
11355+ if (silParsed)
11356+ return nullptr ;
11357+
11358+ Type actorType;
11359+
11360+ if (auto *instance = actorInstance.dyn_cast <VarDecl *>()) {
11361+ actorType = instance->getTypeInContext ();
11362+ } else if (auto *instance = actorInstance.dyn_cast <Expr *>()) {
11363+ actorType = instance->getType ();
11364+ }
11365+
11366+ if (actorType) {
11367+ if (auto wrapped = actorType->getOptionalObjectType ()) {
11368+ actorType = wrapped;
11369+ }
11370+ return actorType->getReferenceStorageReferent ()->getAnyActor ();
11371+ }
11372+
11373+ return actorInstance.get <NominalTypeDecl *>();
11374+ }
11375+
1135111376VarDecl *ActorIsolation::getActorInstance () const {
1135211377 assert (getKind () == ActorInstance);
1135311378
You can’t perform that action at this time.
0 commit comments