@@ -11476,183 +11476,6 @@ void swift::simple_display(llvm::raw_ostream &out, AnyFunctionRef fn) {
1147611476 out << " closure" ;
1147711477}
1147811478
11479- ActorIsolation::ActorIsolation (Kind kind, NominalTypeDecl *actor,
11480- unsigned parameterIndex)
11481- : actorInstance(actor), kind(kind), isolatedByPreconcurrency(false ),
11482- silParsed(false ), parameterIndex(parameterIndex) {}
11483-
11484- ActorIsolation::ActorIsolation (Kind kind, VarDecl *actor,
11485- unsigned parameterIndex)
11486- : actorInstance(actor), kind(kind), isolatedByPreconcurrency(false ),
11487- silParsed(false ), parameterIndex(parameterIndex) {}
11488-
11489- ActorIsolation::ActorIsolation (Kind kind, Expr *actor,
11490- unsigned parameterIndex)
11491- : actorInstance(actor), kind(kind), isolatedByPreconcurrency(false ),
11492- silParsed(false ), parameterIndex(parameterIndex) {}
11493-
11494- ActorIsolation::ActorIsolation (Kind kind, Type globalActor)
11495- : globalActor(globalActor), kind(kind), isolatedByPreconcurrency(false ),
11496- silParsed(false ), parameterIndex(0 ) {}
11497-
11498- ActorIsolation
11499- ActorIsolation::forActorInstanceParameter (Expr *actor,
11500- unsigned parameterIndex) {
11501- auto &ctx = actor->getType ()->getASTContext ();
11502-
11503- // An isolated value of `nil` is statically nonisolated.
11504- // FIXME: Also allow 'Optional.none'
11505- if (dyn_cast<NilLiteralExpr>(actor))
11506- return ActorIsolation::forNonisolated (/* unsafe*/ false );
11507-
11508- // An isolated value of `<global actor type>.shared` is statically
11509- // global actor isolated.
11510- if (auto *memberRef = dyn_cast<MemberRefExpr>(actor)) {
11511- // Check that the member declaration witnesses the `shared`
11512- // requirement of the `GlobalActor` protocol.
11513- auto declRef = memberRef->getDecl ();
11514- auto baseType =
11515- memberRef->getBase ()->getType ()->getMetatypeInstanceType ();
11516- if (auto globalActor = ctx.getProtocol (KnownProtocolKind::GlobalActor)) {
11517- auto conformance = checkConformance (baseType, globalActor);
11518- if (conformance &&
11519- conformance.getWitnessByName (baseType, ctx.Id_shared ) == declRef) {
11520- return ActorIsolation::forGlobalActor (baseType);
11521- }
11522- }
11523- }
11524-
11525- return ActorIsolation (ActorInstance, actor, parameterIndex + 1 );
11526- }
11527-
11528- ActorIsolation
11529- ActorIsolation::forActorInstanceSelf (ValueDecl *decl) {
11530- if (auto *fn = dyn_cast<AbstractFunctionDecl>(decl))
11531- return ActorIsolation (ActorInstance, fn->getImplicitSelfDecl (), 0 );
11532-
11533- if (auto *storage = dyn_cast<AbstractStorageDecl>(decl)) {
11534- if (auto *fn = storage->getAccessor (AccessorKind::Get)) {
11535- return ActorIsolation (ActorInstance, fn->getImplicitSelfDecl (), 0 );
11536- }
11537- }
11538-
11539- auto *dc = decl->getDeclContext ();
11540- return ActorIsolation (ActorInstance, dc->getSelfNominalTypeDecl (), 0 );
11541- }
11542-
11543- ActorIsolation ActorIsolation::forActorInstanceSelf (NominalTypeDecl *selfDecl) {
11544- return ActorIsolation (ActorInstance, selfDecl, 0 );
11545- }
11546-
11547- NominalTypeDecl *ActorIsolation::getActor () const {
11548- assert (getKind () == ActorInstance || getKind () == GlobalActor);
11549-
11550- if (silParsed)
11551- return nullptr ;
11552-
11553- if (getKind () == GlobalActor) {
11554- return getGlobalActor ()->getAnyNominal ();
11555- }
11556-
11557- Type actorType;
11558-
11559- if (auto *instance = actorInstance.dyn_cast <VarDecl *>()) {
11560- actorType = instance->getTypeInContext ();
11561- } else if (auto *expr = actorInstance.dyn_cast <Expr *>()) {
11562- actorType = expr->getType ();
11563- }
11564-
11565- if (actorType) {
11566- if (auto wrapped = actorType->getOptionalObjectType ()) {
11567- actorType = wrapped;
11568- }
11569- return actorType
11570- ->getReferenceStorageReferent ()->getAnyActor ();
11571- }
11572-
11573- return actorInstance.get <NominalTypeDecl *>();
11574- }
11575-
11576- VarDecl *ActorIsolation::getActorInstance () const {
11577- assert (getKind () == ActorInstance);
11578-
11579- if (silParsed)
11580- return nullptr ;
11581-
11582- return actorInstance.dyn_cast <VarDecl *>();
11583- }
11584-
11585- Expr *ActorIsolation::getActorInstanceExpr () const {
11586- assert (getKind () == ActorInstance);
11587-
11588- if (silParsed)
11589- return nullptr ;
11590-
11591- return actorInstance.dyn_cast <Expr *>();
11592- }
11593-
11594- bool ActorIsolation::isMainActor () const {
11595- if (silParsed)
11596- return false ;
11597-
11598- if (isGlobalActor ()) {
11599- if (auto *nominal = getGlobalActor ()->getAnyNominal ())
11600- return nominal->isMainActor ();
11601- }
11602-
11603- return false ;
11604- }
11605-
11606- bool ActorIsolation::isDistributedActor () const {
11607- if (silParsed)
11608- return false ;
11609-
11610- if (getKind () != ActorInstance)
11611- return false ;
11612-
11613- return getActor ()->isDistributedActor ();
11614- }
11615-
11616- bool ActorIsolation::isEqual (const ActorIsolation &lhs,
11617- const ActorIsolation &rhs) {
11618- if (lhs.getKind () != rhs.getKind ())
11619- return false ;
11620-
11621- switch (lhs.getKind ()) {
11622- case Nonisolated:
11623- case NonisolatedUnsafe:
11624- case Unspecified:
11625- return true ;
11626-
11627- case Erased:
11628- // Different functions with erased isolation have the same *kind* of
11629- // isolation, but we must generally assume that they're not isolated
11630- // the *same way*, which is what this function is apparently supposed
11631- // to answer.
11632- return false ;
11633-
11634- case ActorInstance: {
11635- auto *lhsActor = lhs.getActorInstance ();
11636- auto *rhsActor = rhs.getActorInstance ();
11637- if (lhsActor && rhsActor) {
11638- // FIXME: This won't work for arbitrary isolated parameter captures.
11639- if ((lhsActor->isSelfParameter () && rhsActor->isSelfParamCapture ()) ||
11640- (lhsActor->isSelfParamCapture () && rhsActor->isSelfParameter ())) {
11641- return true ;
11642- }
11643- }
11644-
11645- // The parameter index doesn't matter; only the actor instance
11646- // values must be equal.
11647- return (lhs.getActor () == rhs.getActor () &&
11648- lhs.actorInstance == rhs.actorInstance );
11649- }
11650-
11651- case GlobalActor:
11652- return areTypesEqual (lhs.globalActor , rhs.globalActor );
11653- }
11654- }
11655-
1165611479BuiltinTupleDecl::BuiltinTupleDecl (Identifier Name, DeclContext *Parent)
1165711480 : NominalTypeDecl(DeclKind::BuiltinTuple, Parent, Name, SourceLoc(),
1165811481 ArrayRef<InheritedEntry>(), nullptr) {}
0 commit comments