diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b873ddc84b..30d2c32ca58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -418,10 +418,6 @@ option(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY "Enable experimental Swift concurrency model" FALSE) -option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED - "Enable experimental distributed actors and functions" - FALSE) - option(SWIFT_ENABLE_DISPATCH "Enable use of libdispatch" TRUE) @@ -905,7 +901,6 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY) message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}") message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}") - message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}") message(STATUS "") else() message(STATUS "Not building Swift standard library, SDK overlays, and runtime") diff --git a/include/swift/AST/ASTMangler.h b/include/swift/AST/ASTMangler.h index a9fc989333f..729c9c0eb48 100644 --- a/include/swift/AST/ASTMangler.h +++ b/include/swift/AST/ASTMangler.h @@ -88,7 +88,6 @@ public: DynamicThunk, SwiftAsObjCThunk, ObjCAsSwiftThunk, - DistributedThunk, }; ASTMangler(bool DWARFMangling = false) diff --git a/include/swift/AST/ActorIsolation.h b/include/swift/AST/ActorIsolation.h index 7015ca0402c..3d26c419269 100644 --- a/include/swift/AST/ActorIsolation.h +++ b/include/swift/AST/ActorIsolation.h @@ -48,10 +48,6 @@ public: /// For example, a mutable stored property or synchronous function within /// the actor is isolated to the instance of that actor. ActorInstance, - /// The declaration is isolated to a (potentially) distributed actor. - /// Distributed actors may access _their_ state (same as 'ActorInstance') - /// however others may not access any properties on other distributed actors. - DistributedActorInstance, /// The declaration is explicitly specified to be independent of any actor, /// meaning that it can be used from any actor but is also unable to /// refer to the isolated state of any given actor. @@ -92,10 +88,6 @@ public: return ActorIsolation(ActorInstance, actor); } - static ActorIsolation forDistributedActorInstance(NominalTypeDecl *actor) { - return ActorIsolation(DistributedActorInstance, actor); - } - static ActorIsolation forGlobalActor(Type globalActor, bool unsafe) { return ActorIsolation( unsafe ? GlobalActorUnsafe : GlobalActor, globalActor); @@ -108,7 +100,7 @@ public: bool isUnspecified() const { return kind == Unspecified; } NominalTypeDecl *getActor() const { - assert(getKind() == ActorInstance || getKind() == DistributedActorInstance); + assert(getKind() == ActorInstance); return actor; } @@ -139,7 +131,6 @@ public: return true; case ActorInstance: - case DistributedActorInstance: return lhs.actor == rhs.actor; case GlobalActor: diff --git a/include/swift/AST/Attr.def b/include/swift/AST/Attr.def index edee408b669..2eca573e662 100644 --- a/include/swift/AST/Attr.def +++ b/include/swift/AST/Attr.def @@ -655,21 +655,6 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(spawn, Spawn, APIBreakingToAdd | APIBreakingToRemove, 117) -CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor, - DeclModifier | OnClass | OnFunc | - DistributedOnly | - ABIBreakingToAdd | ABIBreakingToRemove | - APIBreakingToAdd | APIBreakingToRemove, - 118) - -SIMPLE_DECL_ATTR(_distributedActorIndependent, DistributedActorIndependent, - OnFunc | OnVar | - DistributedOnly | UserInaccessible | - ABIStableToAdd | ABIStableToRemove | - APIBreakingToAdd | APIBreakingToRemove, - 119) - - #undef TYPE_ATTR #undef DECL_ATTR_ALIAS #undef CONTEXTUAL_DECL_ATTR_ALIAS diff --git a/include/swift/AST/Attr.h b/include/swift/AST/Attr.h index e2798522ecc..bc39a48c31b 100644 --- a/include/swift/AST/Attr.h +++ b/include/swift/AST/Attr.h @@ -294,9 +294,6 @@ public: /// Whether this attribute is only valid when concurrency is enabled. ConcurrencyOnly = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 16), - - /// Whether this attribute is only valid when distributed is enabled. - DistributedOnly = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 17), }; LLVM_READNONE @@ -391,10 +388,6 @@ public: return getOptions(DK) & ConcurrencyOnly; } - static bool isDistributedOnly(DeclAttrKind DK) { - return getOptions(DK) & DistributedOnly; - } - static bool isUserInaccessible(DeclAttrKind DK) { return getOptions(DK) & UserInaccessible; } diff --git a/include/swift/AST/Builtins.def b/include/swift/AST/Builtins.def index 23b14d7dc25..6e591fc1195 100644 --- a/include/swift/AST/Builtins.def +++ b/include/swift/AST/Builtins.def @@ -724,14 +724,6 @@ BUILTIN_MISC_OPERATION(InitializeDefaultActor, "initializeDefaultActor", "", Spe /// Destroy the default-actor instance in a default actor object. BUILTIN_MISC_OPERATION(DestroyDefaultActor, "destroyDefaultActor", "", Special) -/// Initialize a "proxy" for a distributed remote actor. -BUILTIN_MISC_OPERATION(InitializeDistributedRemoteActor, - "initializeDistributedRemoteActor", "", Special) - -/// Destroy the distributed-actor instance in a "proxy" actor object. -BUILTIN_MISC_OPERATION(DestroyDistributedActor, - "destroyDistributedActor", "", Special) - /// Resume a non-throwing continuation normally with the given result. BUILTIN_MISC_OPERATION(ResumeNonThrowingContinuationReturning, "resumeNonThrowingContinuationReturning", "", Special) diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index 6c168eab519..6a74100f566 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -2346,8 +2346,6 @@ public: /// Is this declaration marked with 'dynamic'? bool isDynamic() const; - bool isDistributedActorIndependent() const; - private: bool isObjCDynamic() const { return isObjC() && isDynamic(); @@ -3166,11 +3164,6 @@ public: OptionSet flags = OptionSet()); - /// Find the '_remote_<...>' counterpart function to a 'distributed func'. - /// - /// If the passed in function is not distributed this function returns null. - AbstractFunctionDecl* lookupDirectRemoteFunc(AbstractFunctionDecl *func); - /// Collect the set of protocols to which this type should implicitly /// conform, such as AnyObject (for classes). void getImplicitProtocols(SmallVectorImpl &protocols); @@ -3227,10 +3220,6 @@ public: /// `Actor` protocol. bool isActor() const; - /// Whether this nominal type qualifies as a distributed actor, meaning that - /// it is either a distributed actor. - bool isDistributedActor() const; - /// Return the range of semantics attributes attached to this NominalTypeDecl. auto getSemanticsAttrs() const -> decltype(getAttrs().getSemanticsAttrs()) { @@ -3299,8 +3288,6 @@ public: /// for types that are not global actors. VarDecl *getGlobalActorInstance() const; - bool hasDistributedActorLocalInitializer() const; - /// Whether this type is a global actor, which can be used as an /// attribute to decorate declarations for inclusion in the actor-isolated /// state denoted by this type. @@ -4016,7 +4003,6 @@ enum class KnownDerivableProtocolKind : uint8_t { AdditiveArithmetic, Differentiable, Actor, - DistributedActor, }; /// ProtocolDecl - A declaration of a protocol, for example: @@ -4210,10 +4196,6 @@ public: /// semantics but has no corresponding witness table. bool isMarkerProtocol() const; - /// Is a protocol that can only be conformed by distributed actors. - /// Such protocols are allowed to contain distributed functions. - bool inheritsFromDistributedActor() const; - private: void computeKnownProtocolKind() const; @@ -4732,8 +4714,6 @@ public: bool hasAnyNativeDynamicAccessors() const; - bool isDistributedActorIndependent() const; - // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_AbstractStorageDecl && @@ -5190,7 +5170,7 @@ public: return getAttrs().getAttributes(); } - /// Returns true if this VarDecl has the string \p attrValue as a semantics + /// Returns true if this VarDelc has the string \p attrValue as a semantics /// attribute. bool hasSemanticsAttr(StringRef attrValue) const { return llvm::any_of(getSemanticsAttrs(), [&](const SemanticsAttr *attr) { @@ -5198,12 +5178,6 @@ public: }); } - /// Whether the given name is actorAddress, which is used for distributed actors. - static bool isDistributedActorAddressName(ASTContext &ctx, DeclName name); - - /// Whether the given name is actorTransport, which is used for distributed actors. - static bool isDistributedActorTransportName(ASTContext &ctx, DeclName name); - // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Var || D->getKind() == DeclKind::Param; @@ -5881,9 +5855,6 @@ public: /// Returns if the function is 'rethrows' or 'reasync'. bool hasPolymorphicEffect(EffectKind kind) const; - /// Returns 'true' if the function is distributed. - bool isDistributed() const; - PolymorphicEffectKind getPolymorphicEffectKind(EffectKind kind) const; // FIXME: Hack that provides names with keyword arguments for accessors. @@ -6893,18 +6864,6 @@ public: /// \endcode bool isObjCZeroParameterWithLongSelector() const; - /// Checks if the initializer is a distributed actor's 'local' initializer: - /// ``` - /// init(transport: ActorTransport) - /// ``` - bool isDistributedActorLocalInit() const; - - /// Checks if the initializer is a distributed actor's 'resolve' initializer: - /// ``` - /// init(resolve address: ActorAddress, using transport: ActorTransport) - /// ``` - bool isDistributedActorResolveInit() const; - static bool classof(const Decl *D) { return D->getKind() == DeclKind::Constructor; } diff --git a/include/swift/AST/DiagnosticsParse.def b/include/swift/AST/DiagnosticsParse.def index 70fa6c10beb..423b42abeab 100644 --- a/include/swift/AST/DiagnosticsParse.def +++ b/include/swift/AST/DiagnosticsParse.def @@ -1822,7 +1822,7 @@ ERROR(pound_available_package_description_not_allowed, none, ERROR(availability_query_repeated_platform, none, "version for '%0' already specified", (StringRef)) -ERROR(attr_requires_concurrency, none, +ERROR(attr_requires_concurrency,none, "'%0' %select{attribute|modifier}1 is only valid when experimental " "concurrency is enabled", (StringRef, bool)) diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index be0f5191188..d7fce19b014 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -4362,13 +4362,6 @@ ERROR(actor_isolated_non_self_reference,none, "actor-isolated %0 %1 can only be %select{referenced|mutated|used 'inout'}3 " "%select{from inside the actor|on 'self'}2", (DescriptiveDeclKind, DeclName, bool, unsigned)) -ERROR(distributed_actor_isolated_non_self_reference,none, - "distributed actor-isolated %0 %1 can only be referenced " - "inside the distributed actor", - (DescriptiveDeclKind, DeclName)) -ERROR(distributed_actor_needs_explicit_distributed_import,none, - "'_Distributed' module not imported, required for 'distributed actor'", - ()) ERROR(actor_isolated_self_independent_context,none, "actor-isolated %0 %1 can not be %select{referenced|mutated|used 'inout'}2 from a " "non-isolated context", @@ -4418,8 +4411,8 @@ ERROR(actor_isolated_from_async_let,none, "actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'async let' initializer", (DescriptiveDeclKind, DeclName, unsigned)) ERROR(actor_isolated_keypath_component,none, - "cannot form key path to%select{| distributed}0 actor-isolated %1 %2", - (bool, DescriptiveDeclKind, DeclName)) + "cannot form key path to actor-isolated %0 %1", + (DescriptiveDeclKind, DeclName)) ERROR(effectful_keypath_component,none, "cannot form key path to %0 with 'throws' or 'async'", (DescriptiveDeclKind)) @@ -4434,32 +4427,6 @@ NOTE(actor_isolated_sync_func,none, "calls to %0 %1 from outside of its actor context are " "implicitly asynchronous", (DescriptiveDeclKind, DeclName)) -NOTE(distributed_actor_isolated_method_note,none, - "only 'distributed' functions can be called from outside the distributed actor", - ()) -ERROR(distributed_actor_isolated_method,none, - "only 'distributed' functions can be called from outside the distributed actor", // TODO: more like 'non-distributed' ... defined here - ()) -ERROR(distributed_actor_func_param_not_codable,none, - "distributed function parameter '%0' of type %1 does not conform to 'Codable'", - (StringRef, Type)) -ERROR(distributed_actor_func_result_not_codable,none, - "distributed function result type %0 does not conform to 'Codable'", - (Type)) -ERROR(distributed_actor_func_missing_remote_func,none, - "distributed function is missing its remote static func implementation (%0). " - "You may want to use a distributed actor SwiftPM plugin to generate those, " - "or implement it manually.", - (Identifier)) -ERROR(distributed_actor_remote_func_is_not_static,none, - "remote function %0 must be static.", - (DeclName)) -ERROR(distributed_actor_remote_func_is_not_async_throws,none, - "remote function %0 must be 'async throws'.", - (DeclName)) -ERROR(distributed_actor_remote_func_must_not_be_distributed,none, - "remote function %0 must be 'async throws'.", - (DeclName)) NOTE(actor_mutable_state,none, "mutation of this %0 is only permitted within the actor", (DescriptiveDeclKind)) @@ -4538,60 +4505,6 @@ ERROR(actor_instance_property_wrapper,none, "the actor instance; consider 'nonisolated'", (Identifier, Identifier)) -ERROR(distributed_actor_func_defined_outside_of_distributed_actor,none, - "distributed function %0 is declared outside of an distributed actor", - (DeclName)) -ERROR(distributed_actor_local_init_explicitly_defined,none, - "'distributed actor' local-initializer 'init(transport:)' " - "cannot be implemented explicitly.", - ()) -ERROR(distributed_actor_init_resolve_must_not_be_user_defined,none, - "'distributed actor' resolve-initializer 'init(resolve:using:)' " - "cannot be implemented explicitly.", - ()) -ERROR(distributed_actor_init_user_defined_must_be_convenience,none, - "'distributed actor' initializer %0 must be 'convenience' initializer. " - "Distributed actors have an implicitly synthesized designated " - "'init(transport:)' local-initializer, which other initializers must delegate to", - (DeclName)) -ERROR(distributed_actor_init_must_delegate_to_local_init,none, - "'distributed actor' initializer %0 must (directly or indirectly) delegate " - "to 'init(transport:)'", - (DeclName)) -ERROR(distributed_actor_init_must_not_delegate_to_resolve_init,none, - "'distributed actor' initializer %0 cannot delegate to resolve-initializer " - "'init(resolve:using:)', as it may result resolving a storageless proxy instance", - (DeclName)) -ERROR(distributed_actor_local_var,none, - "'distributed' can not be applied to local variables", - ()) -ERROR(distributed_actor_property,none, - "'distributed' can not be applied to local properties", - ()) -ERROR(distributed_actor_storage,none, - "'distributed' can not be applied to actor properties; " - "Only functions can be 'distributed'", - ()) -ERROR(distributed_actor_not_actor,none, - "'distributed' can only be applied to 'actor' definitions, " - "and distributed actor-isolated async functions", - ()) -ERROR(distributed_actor_not_actor_func,none, - "'distributed' can only be applied to distributed actor async functions", - ()) -ERROR(distributed_actor_func_static,none, - "'distributed' functions cannot be 'static'", - ()) -ERROR(distributed_actor_func_not_in_distributed_actor,none, - "'distributed' function can only be declared within 'distributed actor'", - ()) -ERROR(distributed_actor_independent_property_must_be_let,none, - "_distributedActorIndependent can be applied to properties, however they must be 'let'", - ()) -NOTE(distributed_actor_isolated_property,none, - "distributed actor state is only available within the actor instance", - ()) - ERROR(concurrency_lib_missing,none, "missing '%0' declaration, probably because the '_Concurrency' " "module was not imported", (StringRef)) diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h index e397475bd60..f3f7044997a 100644 --- a/include/swift/AST/Expr.h +++ b/include/swift/AST/Expr.h @@ -166,10 +166,9 @@ protected: SWIFT_INLINE_BITFIELD_EMPTY(LiteralExpr, Expr); SWIFT_INLINE_BITFIELD_EMPTY(IdentityExpr, Expr); - SWIFT_INLINE_BITFIELD(LookupExpr, Expr, 1+1+1, + SWIFT_INLINE_BITFIELD(LookupExpr, Expr, 1+1, IsSuper : 1, - IsImplicitlyAsync : 1, - IsImplicitlyThrows : 1 + IsImplicitlyAsync : 1 ); SWIFT_INLINE_BITFIELD_EMPTY(DynamicLookupExpr, LookupExpr); @@ -195,11 +194,10 @@ protected: LiteralCapacity : 32 ); - SWIFT_INLINE_BITFIELD(DeclRefExpr, Expr, 2+2+1+1, + SWIFT_INLINE_BITFIELD(DeclRefExpr, Expr, 2+2+1, Semantics : 2, // an AccessSemantics FunctionRefKind : 2, - IsImplicitlyAsync : 1, - IsImplicitlyThrows : 1 + IsImplicitlyAsync : 1 ); SWIFT_INLINE_BITFIELD(UnresolvedDeclRefExpr, Expr, 2+2, @@ -347,11 +345,10 @@ protected: NumCaptures : 32 ); - SWIFT_INLINE_BITFIELD(ApplyExpr, Expr, 1+1+1+1+1, + SWIFT_INLINE_BITFIELD(ApplyExpr, Expr, 1+1+1+1, ThrowsIsSet : 1, Throws : 1, ImplicitlyAsync : 1, - ImplicitlyThrows : 1, NoAsync : 1 ); @@ -1205,7 +1202,6 @@ public: static_cast(Loc.isCompound() ? FunctionRefKind::Compound : FunctionRefKind::Unapplied); Bits.DeclRefExpr.IsImplicitlyAsync = false; - Bits.DeclRefExpr.IsImplicitlyThrows = false; } /// Retrieve the declaration to which this expression refers. @@ -1229,22 +1225,6 @@ public: Bits.DeclRefExpr.IsImplicitlyAsync = isImplicitlyAsync; } - /// Determine whether this reference needs may implicitly throw. - /// - /// This is the case for non-throwing `distributed func` declarations, - /// which are cross-actor invoked, because such calls actually go over the - /// transport/network, and may throw from this, rather than the function - /// implementation itself.. - bool isImplicitlyThrows() const { return Bits.DeclRefExpr.IsImplicitlyThrows; } - - /// Set whether this reference must account for a `throw` occurring for reasons - /// other than the function implementation itself throwing, e.g. an - /// `ActorTransport` implementing a `distributed func` call throwing a - /// networking error. - void setImplicitlyThrows(bool isImplicitlyThrows) { - Bits.DeclRefExpr.IsImplicitlyThrows = isImplicitlyThrows; - } - /// Retrieve the concrete declaration reference. ConcreteDeclRef getDeclRef() const { return D; @@ -1561,7 +1541,6 @@ protected: : Expr(Kind, Implicit), Base(base), Member(member) { Bits.LookupExpr.IsSuper = false; Bits.LookupExpr.IsImplicitlyAsync = false; - Bits.LookupExpr.IsImplicitlyThrows = false; assert(Base); } @@ -1601,22 +1580,6 @@ public: Bits.LookupExpr.IsImplicitlyAsync = isImplicitlyAsync; } - /// Determine whether this reference needs may implicitly throw. - /// - /// This is the case for non-throwing `distributed func` declarations, - /// which are cross-actor invoked, because such calls actually go over the - /// transport/network, and may throw from this, rather than the function - /// implementation itself.. - bool isImplicitlyThrows() const { return Bits.LookupExpr.IsImplicitlyThrows; } - - /// Set whether this reference must account for a `throw` occurring for reasons - /// other than the function implementation itself throwing, e.g. an - /// `ActorTransport` implementing a `distributed func` call throwing a - /// networking error. - void setImplicitlyThrows(bool isImplicitlyThrows) { - Bits.LookupExpr.IsImplicitlyThrows = isImplicitlyThrows; - } - static bool classof(const Expr *E) { return E->getKind() >= ExprKind::First_LookupExpr && E->getKind() <= ExprKind::Last_LookupExpr; @@ -4495,7 +4458,6 @@ protected: assert(validateArg(Arg) && "Arg is not a permitted expr kind"); Bits.ApplyExpr.ThrowsIsSet = false; Bits.ApplyExpr.ImplicitlyAsync = false; - Bits.ApplyExpr.ImplicitlyThrows = false; Bits.ApplyExpr.NoAsync = false; } @@ -4563,19 +4525,6 @@ public: Bits.ApplyExpr.ImplicitlyAsync = flag; } - /// Is this application _implicitly_ required to be a throwing call? - /// This can happen if the function is actually a proxy function invocation, - /// which may throw, regardless of the target function throwing, e.g. - /// a distributed function call on a 'remote' actor, may throw due to network - /// issues reported by the transport, regardless if the actual target function - /// can throw. - bool implicitlyThrows() const { - return Bits.ApplyExpr.ImplicitlyThrows; - } - void setImplicitlyThrows(bool flag) { - Bits.ApplyExpr.ImplicitlyThrows = flag; - } - ValueDecl *getCalledValue() const; /// Retrieve the argument labels provided at the call site. diff --git a/include/swift/AST/KnownIdentifiers.def b/include/swift/AST/KnownIdentifiers.def index faeda2a9c5e..5b4c0ec1afd 100644 --- a/include/swift/AST/KnownIdentifiers.def +++ b/include/swift/AST/KnownIdentifiers.def @@ -56,7 +56,6 @@ IDENTIFIER(CoreFoundation) IDENTIFIER(count) IDENTIFIER(CVarArg) IDENTIFIER(Darwin) -IDENTIFIER_(Distributed) IDENTIFIER(dealloc) IDENTIFIER(debugDescription) IDENTIFIER(Decodable) @@ -246,21 +245,6 @@ IDENTIFIER(pullback) IDENTIFIER(TangentVector) IDENTIFIER(zero) -// Distributed actors -IDENTIFIER(transport) -IDENTIFIER(using) -IDENTIFIER(actor) -IDENTIFIER(actorTransport) -IDENTIFIER(actorType) -IDENTIFIER(actorReady) -IDENTIFIER(assignAddress) -IDENTIFIER(resolve) -IDENTIFIER(address) -IDENTIFIER(actorAddress) -IDENTIFIER(_distributedActorRemoteInitialize) -IDENTIFIER(_distributedActorDestroy) -IDENTIFIER(__isRemoteActor) - #undef IDENTIFIER #undef IDENTIFIER_ #undef IDENTIFIER_WITH_NAME diff --git a/include/swift/AST/KnownProtocols.def b/include/swift/AST/KnownProtocols.def index 953bf70a04c..2880a265235 100644 --- a/include/swift/AST/KnownProtocols.def +++ b/include/swift/AST/KnownProtocols.def @@ -59,7 +59,6 @@ BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(name, "_" #name) PROTOCOL(Actor) -PROTOCOL(DistributedActor) PROTOCOL(Sequence) PROTOCOL(IteratorProtocol) PROTOCOL(RawRepresentable) diff --git a/include/swift/AST/KnownSDKTypes.def b/include/swift/AST/KnownSDKTypes.def index 450a93b51c5..4ff96c5d253 100644 --- a/include/swift/AST/KnownSDKTypes.def +++ b/include/swift/AST/KnownSDKTypes.def @@ -43,9 +43,4 @@ KNOWN_SDK_TYPE_DECL(Concurrency, UnownedSerialExecutor, NominalTypeDecl, 0) KNOWN_SDK_TYPE_DECL(Concurrency, TaskLocal, ClassDecl, 1) -// Distributed actors -KNOWN_SDK_TYPE_DECL(Distributed, DistributedActor, ProtocolDecl, 0) -KNOWN_SDK_TYPE_DECL(Distributed, ActorTransport, ProtocolDecl, 0) -KNOWN_SDK_TYPE_DECL(Distributed, ActorAddress, StructDecl, 0) - #undef KNOWN_SDK_TYPE_DECL diff --git a/include/swift/AST/TypeCheckRequests.h b/include/swift/AST/TypeCheckRequests.h index 89cf6b8263e..1506b8f0aa3 100644 --- a/include/swift/AST/TypeCheckRequests.h +++ b/include/swift/AST/TypeCheckRequests.h @@ -915,42 +915,6 @@ public: bool isCached() const { return true; } }; -/// Determine whether the given class is an distributed actor. -class IsDistributedActorRequest : - public SimpleRequest { -public: - using SimpleRequest::SimpleRequest; - -private: - friend SimpleRequest; - - bool evaluate(Evaluator &evaluator, NominalTypeDecl *nominal) const; - -public: - // Caching - bool isCached() const { return true; } -}; - -/// Determine whether the given func is distributed. -class IsDistributedFuncRequest : - public SimpleRequest { -public: - using SimpleRequest::SimpleRequest; - -private: - friend SimpleRequest; - - bool evaluate(Evaluator &evaluator, FuncDecl *func) const; - -public: - // Caching - bool isCached() const { return true; } -}; - /// Retrieve the static "shared" property within a global actor that provides /// the actor instance representing the global actor. /// @@ -1941,24 +1905,6 @@ public: bool isCached() const { return true; } }; -/// Checks whether this type has a distributed actor "local" initializer. -class HasDistributedActorLocalInitRequest - : public SimpleRequest { -public: - using SimpleRequest::SimpleRequest; - -private: - friend SimpleRequest; - - // Evaluation. - bool evaluate(Evaluator &evaluator, NominalTypeDecl *decl) const; - -public: - // Caching. - bool isCached() const { return true; } -}; - /// Synthesizes a default initializer for a given type. class SynthesizeDefaultInitRequest : public SimpleRequest, HelpText<"Enable experimental concurrency model">; -def enable_experimental_distributed : - Flag<["-"], "enable-experimental-distributed">, - HelpText<"Enable experimental 'distributed' actors and functions">; - def enable_experimental_flow_sensitive_concurrent_captures : Flag<["-"], "enable-experimental-flow-sensitive-concurrent-captures">, HelpText<"Enable flow-sensitive concurrent captures">; @@ -294,10 +290,6 @@ def disable_implicit_concurrency_module_import : Flag<["-"], "disable-implicit-concurrency-module-import">, HelpText<"Disable the implicit import of the _Concurrency module.">; -def disable_implicit_distributed_module_import : Flag<["-"], - "disable-implicit-distributed-module-import">, - HelpText<"Disable the implicit import of the _Distributed module.">; - def disable_arc_opts : Flag<["-"], "disable-arc-opts">, HelpText<"Don't run SIL ARC optimization passes.">; def disable_ossa_opts : Flag<["-"], "disable-ossa-opts">, diff --git a/include/swift/Parse/Parser.h b/include/swift/Parse/Parser.h index 17e0118ab67..23e8c7d5f36 100644 --- a/include/swift/Parse/Parser.h +++ b/include/swift/Parse/Parser.h @@ -745,14 +745,6 @@ public: Context.LangOpts.ParseForSyntaxTreeOnly; } - /// Returns true to indicate that experimental 'distributed actor' syntax - /// should be parsed if the parser is only a syntax tree or if the user has - /// passed the `-enable-experimental-distributed' flag to the frontend. - bool shouldParseExperimentalDistributed() const { - return Context.LangOpts.EnableExperimentalDistributed || - Context.LangOpts.ParseForSyntaxTreeOnly; - } - public: InFlightDiagnostic diagnose(SourceLoc Loc, Diagnostic Diag) { if (Diags.isDiagnosticPointsToFirstBadToken(Diag.getID()) && diff --git a/include/swift/Runtime/Concurrency.h b/include/swift/Runtime/Concurrency.h index f69c450f5db..e53c5d9b336 100644 --- a/include/swift/Runtime/Concurrency.h +++ b/include/swift/Runtime/Concurrency.h @@ -608,14 +608,6 @@ void swift_defaultActor_deallocate(DefaultActor *actor); SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift) void swift_defaultActor_deallocateResilient(HeapObject *actor); -/// Initialize the runtime storage for a distributed remote actor. -SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift) -void swift_distributedActor_remote_initialize(DefaultActor *actor); - -/// Destroy the runtime storage for a default actor. -SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift) -void swift_distributedActor_destroy(DefaultActor *actor); - /// Enqueue a job on the default actor implementation. /// /// The job must be ready to run. Notably, if it's a task, that @@ -631,10 +623,6 @@ void swift_distributedActor_destroy(DefaultActor *actor); SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift) void swift_defaultActor_enqueue(Job *job, DefaultActor *actor); -/// Check if the actor is a distributed 'remote' actor instance. -SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift) -bool swift_distributed_actor_is_remote(DefaultActor *actor); - /// Prepare a continuation in the current task. /// /// The caller should initialize the Parent, ResumeParent, diff --git a/include/swift/Runtime/RuntimeFunctions.def b/include/swift/Runtime/RuntimeFunctions.def index 88618638057..b0c677b135e 100644 --- a/include/swift/Runtime/RuntimeFunctions.def +++ b/include/swift/Runtime/RuntimeFunctions.def @@ -1678,22 +1678,6 @@ FUNCTION(DefaultActorDeallocateResilient, ARGS(RefCountedPtrTy), ATTRS(NoUnwind)) -// void swift_distributedActor_remote_initialize(DefaultActor *actor); -FUNCTION(DistributedActorInitializeRemote, - swift_distributedActor_remote_initialize, SwiftCC, - ConcurrencyAvailability, - RETURNS(VoidTy), - ARGS(RefCountedPtrTy), // TODO also address and transport? - ATTRS(NoUnwind)) - -// void swift_distributedActor_destroy(DefaultActor *actor); // TODO: ProxyActor *proxy? -FUNCTION(DistributedActorDestroy, - swift_distributedActor_destroy, SwiftCC, - ConcurrencyAvailability, - RETURNS(VoidTy), - ARGS(RefCountedPtrTy), - ATTRS(NoUnwind)) - /// void swift_asyncLet_start( /// AsyncLet *alet, /// const Metadata *futureResultType, diff --git a/include/swift/SIL/SILDeclRef.h b/include/swift/SIL/SILDeclRef.h index b5d939eede3..2f1b72ac21b 100644 --- a/include/swift/SIL/SILDeclRef.h +++ b/include/swift/SIL/SILDeclRef.h @@ -164,8 +164,6 @@ struct SILDeclRef { Kind kind : 4; /// True if this references a foreign entry point for the referenced decl. unsigned isForeign : 1; - /// True if this references a distributed function. - unsigned isDistributed : 1; /// The default argument index for a default argument getter. unsigned defaultArgIndex : 10; @@ -200,13 +198,11 @@ struct SILDeclRef { /// Produces a null SILDeclRef. SILDeclRef() - : loc(), kind(Kind::Func), isForeign(0), isDistributed(0), defaultArgIndex(0) {} + : loc(), kind(Kind::Func), isForeign(0), defaultArgIndex(0) {} /// Produces a SILDeclRef of the given kind for the given decl. explicit SILDeclRef( - ValueDecl *decl, Kind kind, - bool isForeign = false, - bool isDistributed = false, + ValueDecl *decl, Kind kind, bool isForeign = false, AutoDiffDerivativeFunctionIdentifier *derivativeId = nullptr); /// Produces a SILDeclRef for the given ValueDecl or @@ -220,7 +216,7 @@ struct SILDeclRef { /// for the containing ClassDecl. /// - If 'loc' is a global VarDecl, this returns its GlobalAccessor /// SILDeclRef. - explicit SILDeclRef(Loc loc, bool isForeign = false, bool isDistributed = false); + explicit SILDeclRef(Loc loc, bool isForeign = false); /// See above put produces a prespecialization according to the signature. explicit SILDeclRef(Loc loc, GenericSignature prespecializationSig); @@ -344,14 +340,12 @@ struct SILDeclRef { friend llvm::hash_code hash_value(const SILDeclRef &ref) { return llvm::hash_combine(ref.loc.getOpaqueValue(), static_cast(ref.kind), - ref.isForeign, ref.isDistributed, - ref.defaultArgIndex); + ref.isForeign, ref.defaultArgIndex); } bool operator==(SILDeclRef rhs) const { return loc.getOpaqueValue() == rhs.loc.getOpaqueValue() && kind == rhs.kind && isForeign == rhs.isForeign && - isDistributed == rhs.isDistributed && defaultArgIndex == rhs.defaultArgIndex && pointer == rhs.pointer; } @@ -367,19 +361,7 @@ struct SILDeclRef { /// Returns the foreign (or native) entry point corresponding to the same /// decl. SILDeclRef asForeign(bool foreign = true) const { - return SILDeclRef(loc.getOpaqueValue(), kind, - /*foreign=*/foreign, - /*distributed=*/false, - defaultArgIndex, - pointer.get()); - } - /// Returns the distributed entry point corresponding to the same - /// decl. - SILDeclRef asDistributed(bool distributed = true) const { - return SILDeclRef(loc.getOpaqueValue(), kind, - /*foreign=*/false, - /*distributed=*/distributed, - defaultArgIndex, + return SILDeclRef(loc.getOpaqueValue(), kind, foreign, defaultArgIndex, pointer.get()); } @@ -409,20 +391,14 @@ struct SILDeclRef { return result; } - /// True is the decl ref references any kind of thunk. - bool isAnyThunk() const; - /// True if the decl ref references a thunk from a natively foreign /// declaration to Swift calling convention. bool isForeignToNativeThunk() const; - + /// True if the decl ref references a thunk from a natively Swift declaration /// to foreign C or ObjC calling convention. bool isNativeToForeignThunk() const; - /// True if the decl ref references a thunk handling potentially distributed actor functions - bool isDistributedThunk() const; - /// True if the decl ref references a method which introduces a new vtable /// entry. bool requiresNewVTableEntry() const; @@ -497,14 +473,11 @@ struct SILDeclRef { private: friend struct llvm::DenseMapInfo; /// Produces a SILDeclRef from an opaque value. - explicit SILDeclRef(void *opaqueLoc, Kind kind, - bool isForeign, - bool isDistributed, + explicit SILDeclRef(void *opaqueLoc, Kind kind, bool isForeign, unsigned defaultArgIndex, AutoDiffDerivativeFunctionIdentifier *derivativeId) : loc(Loc::getFromOpaqueValue(opaqueLoc)), kind(kind), - isForeign(isForeign), isDistributed(isDistributed), - defaultArgIndex(defaultArgIndex), + isForeign(isForeign), defaultArgIndex(defaultArgIndex), pointer(derivativeId) {} }; @@ -526,12 +499,12 @@ template<> struct DenseMapInfo { using UnsignedInfo = DenseMapInfo; static SILDeclRef getEmptyKey() { - return SILDeclRef(PointerInfo::getEmptyKey(), Kind::Func, false, false, 0, + return SILDeclRef(PointerInfo::getEmptyKey(), Kind::Func, false, 0, nullptr); } static SILDeclRef getTombstoneKey() { - return SILDeclRef(PointerInfo::getTombstoneKey(), Kind::Func, false, false, - 0, nullptr); + return SILDeclRef(PointerInfo::getTombstoneKey(), Kind::Func, false, 0, + nullptr); } static unsigned getHashValue(swift::SILDeclRef Val) { unsigned h1 = PointerInfo::getHashValue(Val.loc.getOpaqueValue()); @@ -541,8 +514,7 @@ template<> struct DenseMapInfo { : 0; unsigned h4 = UnsignedInfo::getHashValue(Val.isForeign); unsigned h5 = PointerInfo::getHashValue(Val.pointer.getOpaqueValue()); - unsigned h6 = UnsignedInfo::getHashValue(Val.isDistributed); - return h1 ^ (h2 << 4) ^ (h3 << 9) ^ (h4 << 7) ^ (h5 << 11) ^ (h6 << 8); + return h1 ^ (h2 << 4) ^ (h3 << 9) ^ (h4 << 7) ^ (h5 << 11); } static bool isEqual(swift::SILDeclRef const &LHS, swift::SILDeclRef const &RHS) { diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 47cd869d9e8..c00b1d8c2bf 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1005,9 +1005,6 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const { case KnownProtocolKind::SerialExecutor: M = getLoadedModule(Id_Concurrency); break; - case KnownProtocolKind::DistributedActor: - M = getLoadedModule(Id_Distributed); - break; default: M = getStdlibModule(); break; diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index 623a00b08d3..d7334f37fbb 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -821,7 +821,6 @@ void ASTMangler::appendSymbolKind(SymbolKind SKind) { case SymbolKind::DynamicThunk: return appendOperator("TD"); case SymbolKind::SwiftAsObjCThunk: return appendOperator("To"); case SymbolKind::ObjCAsSwiftThunk: return appendOperator("TO"); - case SymbolKind::DistributedThunk: return appendOperator("Td"); } } diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp index 6c686cb5367..f0525019700 100644 --- a/lib/AST/ASTVerifier.cpp +++ b/lib/AST/ASTVerifier.cpp @@ -1799,7 +1799,7 @@ public: E->dump(Out); Out << "\n"; abort(); - } else if (E->throws() && !FT->isThrowing() && !E->implicitlyThrows()) { + } else if (E->throws() && !FT->isThrowing()) { PolymorphicEffectKind rethrowingKind = PolymorphicEffectKind::Invalid; if (auto DRE = dyn_cast(E->getFn())) { if (auto fnDecl = dyn_cast(DRE->getDecl())) { diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index e3f5e7f7ead..c67e9ec70ed 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -1462,13 +1462,6 @@ static ValueDecl *getDefaultActorInitDestroy(ASTContext &ctx, _void); } -static ValueDecl *getDistributedActorInitDestroy(ASTContext &ctx, - Identifier id) { - return getBuiltinFunction(ctx, id, _thin, - _parameters(_nativeObject), // TODO: no idea if to pass more here? - _void); -} - static ValueDecl *getResumeContinuationReturning(ASTContext &ctx, Identifier id) { return getBuiltinFunction(ctx, id, _thin, @@ -2797,10 +2790,6 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) { case BuiltinValueKind::DestroyDefaultActor: return getDefaultActorInitDestroy(Context, Id); - case BuiltinValueKind::InitializeDistributedRemoteActor: - case BuiltinValueKind::DestroyDistributedActor: - return getDistributedActorInitDestroy(Context, Id); - case BuiltinValueKind::StartAsyncLet: return getStartAsyncLet(Context, Id); diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 72230d5e2ed..8067aa6d334 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2842,10 +2842,6 @@ bool ValueDecl::isDynamic() const { getAttrs().hasAttribute()); } -bool ValueDecl::isDistributedActorIndependent() const { - return getAttrs().hasAttribute(); -} - bool ValueDecl::isObjCDynamicInGenericClass() const { if (!isObjCDynamic()) return false; @@ -3827,12 +3823,6 @@ bool NominalTypeDecl::isActor() const { false); } -bool NominalTypeDecl::isDistributedActor() const { - auto mutableThis = const_cast(this); - return evaluateOrDefault(getASTContext().evaluator, - IsDistributedActorRequest{mutableThis}, - false); -} GenericTypeDecl::GenericTypeDecl(DeclKind K, DeclContext *DC, Identifier name, SourceLoc nameLoc, @@ -4139,13 +4129,6 @@ ConstructorDecl *NominalTypeDecl::getDefaultInitializer() const { SynthesizeDefaultInitRequest{mutableThis}, nullptr); } -bool NominalTypeDecl::hasDistributedActorLocalInitializer() const { - auto &ctx = getASTContext(); - auto *mutableThis = const_cast(this); - return evaluateOrDefault(ctx.evaluator, HasDistributedActorLocalInitRequest{mutableThis}, - false); -} - void NominalTypeDecl::synthesizeSemanticMembersIfNeeded(DeclName member) { // Silently break cycles here because we can't be sure when and where a // request to synthesize will come from yet. @@ -4168,25 +4151,16 @@ void NominalTypeDecl::synthesizeSemanticMembersIfNeeded(DeclName member) { } } else { auto argumentNames = member.getArgumentNames(); - if (member.isSimpleName() || argumentNames.size() == 1) { - if (baseName == DeclBaseName::createConstructor()) { - if ((member.isSimpleName() || argumentNames.front() == Context.Id_from)) { - action.emplace(ImplicitMemberAction::ResolveDecodable); - } else if (argumentNames.front() == Context.Id_transport) { - action.emplace(ImplicitMemberAction::ResolveDistributedActor); - } + if (!member.isCompoundName() || argumentNames.size() == 1) { + if (baseName == DeclBaseName::createConstructor() && + (member.isSimpleName() || argumentNames.front() == Context.Id_from)) { + action.emplace(ImplicitMemberAction::ResolveDecodable); } else if (!baseName.isSpecial() && - baseName.getIdentifier() == Context.Id_encode && - (member.isSimpleName() || argumentNames.front() == Context.Id_to)) { + baseName.getIdentifier() == Context.Id_encode && + (member.isSimpleName() || + argumentNames.front() == Context.Id_to)) { action.emplace(ImplicitMemberAction::ResolveEncodable); } - } else if (member.isSimpleName() || argumentNames.size() == 2) { - if (baseName == DeclBaseName::createConstructor()) { - if (argumentNames[0] == Context.Id_resolve && - argumentNames[1] == Context.Id_using) { - action.emplace(ImplicitMemberAction::ResolveDistributedActor); - } - } } } @@ -4729,11 +4703,6 @@ bool ProtocolDecl::isMarkerProtocol() const { return getAttrs().hasAttribute(); } -bool ProtocolDecl::inheritsFromDistributedActor() const { - auto &C = getASTContext(); - return inheritsFrom(C.getDistributedActorDecl()); -} - ArrayRef ProtocolDecl::getInheritedProtocols() const { auto *mutThis = const_cast(this); return evaluateOrDefault(getASTContext().evaluator, @@ -5186,8 +5155,6 @@ Optional return KnownDerivableProtocolKind::Differentiable; case KnownProtocolKind::Actor: return KnownDerivableProtocolKind::Actor; - case KnownProtocolKind::DistributedActor: - return KnownDerivableProtocolKind::DistributedActor; default: return None; } } @@ -5230,10 +5197,6 @@ bool AbstractStorageDecl::hasAnyNativeDynamicAccessors() const { return false; } -bool AbstractStorageDecl::isDistributedActorIndependent() const { - return getAttrs().hasAttribute(); -} - void AbstractStorageDecl::setAccessors(SourceLoc lbraceLoc, ArrayRef accessors, SourceLoc rbraceLoc) { @@ -6994,17 +6957,6 @@ bool AbstractFunctionDecl::isSendable() const { return getAttrs().hasAttribute(); } -bool AbstractFunctionDecl::isDistributed() const { - auto func = dyn_cast(this); - if (!func) - return false; - - auto mutableFunc = const_cast(func); - return evaluateOrDefault(getASTContext().evaluator, - IsDistributedFuncRequest{mutableFunc}, - false); -} - BraceStmt *AbstractFunctionDecl::getBody(bool canSynthesize) const { if ((getBodyKind() == BodyKind::Synthesize || getBodyKind() == BodyKind::Unparsed) && @@ -7729,17 +7681,6 @@ bool FuncDecl::isMainTypeMainMethod() const { getParameters()->size() == 0; } -bool VarDecl::isDistributedActorAddressName(ASTContext &ctx, DeclName name) { - assert(name.getArgumentNames().size() == 0); - return name.getBaseName() == ctx.Id_actorAddress; -} - -bool VarDecl::isDistributedActorTransportName(ASTContext &ctx, DeclName name) { - assert(name.getArgumentNames().size() == 0); - return name.getBaseName() == ctx.Id_transport || - name.getBaseName() == ctx.Id_actorTransport; -} - ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc, bool Failable, SourceLoc FailabilityLoc, bool Async, SourceLoc AsyncLoc, @@ -7794,47 +7735,6 @@ bool ConstructorDecl::isObjCZeroParameterWithLongSelector() const { return params->get(0)->getInterfaceType()->isVoid(); } -bool ConstructorDecl::isDistributedActorLocalInit() const { - auto name = getName(); - auto argumentNames = name.getArgumentNames(); - - if (argumentNames.size() != 1) - return false; - - auto &C = getASTContext(); - if (argumentNames[0] != C.Id_transport) - return false; - - auto *params = getParameters(); - assert(params->size() == 1); - - auto transportType = C.getActorTransportDecl()->getDeclaredInterfaceType(); - return params->get(0)->getInterfaceType()->isEqual(transportType); -} - -bool ConstructorDecl::isDistributedActorResolveInit() const { - auto name = getName(); - auto argumentNames = name.getArgumentNames(); - - if (argumentNames.size() != 2) - return false; - - auto &C = getASTContext(); - if (argumentNames[0] != C.Id_resolve || - argumentNames[1] != C.Id_using) - return false; - - auto *params = getParameters(); - assert(params->size() == 2); - - auto addressType = C.getActorAddressDecl()->getDeclaredInterfaceType(); - auto transportType = C.getActorTransportDecl()->getDeclaredInterfaceType(); - - return params->get(0)->getInterfaceType()->isEqual(addressType) && - params->get(1)->getInterfaceType()->isEqual(transportType); -} - - DestructorDecl::DestructorDecl(SourceLoc DestructorLoc, DeclContext *Parent) : AbstractFunctionDecl(DeclKind::Destructor, Parent, DeclBaseName::createDestructor(), DestructorLoc, diff --git a/lib/AST/DiagnosticEngine.cpp b/lib/AST/DiagnosticEngine.cpp index 4d8d643659a..13a3fe5f37c 100644 --- a/lib/AST/DiagnosticEngine.cpp +++ b/lib/AST/DiagnosticEngine.cpp @@ -757,10 +757,6 @@ static void formatDiagnosticArgument(StringRef Modifier, Out << "actor-isolated"; break; - case ActorIsolation::DistributedActorInstance: - Out << "distributed actor-isolated"; - break; - case ActorIsolation::GlobalActor: case ActorIsolation::GlobalActorUnsafe: { Type globalActor = isolation.getGlobalActor(); diff --git a/lib/AST/NameLookup.cpp b/lib/AST/NameLookup.cpp index 162bf39634a..5931f311952 100644 --- a/lib/AST/NameLookup.cpp +++ b/lib/AST/NameLookup.cpp @@ -1401,30 +1401,6 @@ NominalTypeDecl::lookupDirect(DeclName name, DirectLookupRequest({this, name, flags}), {}); } -AbstractFunctionDecl* -NominalTypeDecl::lookupDirectRemoteFunc(AbstractFunctionDecl *func) { - auto &C = func->getASTContext(); - auto *selfTyDecl = func->getParent()->getSelfNominalTypeDecl(); - - // _remote functions only exist as counterparts to a distributed function. - if (!func->isDistributed()) - return nullptr; - - auto localFuncName = func->getBaseIdentifier().str().str(); - auto remoteFuncId = C.getIdentifier("_remote_" + localFuncName); - - auto remoteFuncDecls = selfTyDecl->lookupDirect(DeclName(remoteFuncId)); - if (remoteFuncDecls.empty()) - return nullptr; - - if (auto remoteDecl = dyn_cast(remoteFuncDecls.front())) { - // TODO: implement more checks here, it has to be the exact right signature. - return remoteDecl; - } - - return nullptr; -} - TinyPtrVector DirectLookupRequest::evaluate(Evaluator &evaluator, DirectLookupDescriptor desc) const { diff --git a/lib/AST/ProtocolConformance.cpp b/lib/AST/ProtocolConformance.cpp index b6e81f2d72e..9dc0c0f8d20 100644 --- a/lib/AST/ProtocolConformance.cpp +++ b/lib/AST/ProtocolConformance.cpp @@ -1252,8 +1252,6 @@ void NominalTypeDecl::prepareConformanceTable() const { if (auto classDecl = dyn_cast(mutableThis)) { if (classDecl->isActor()) addSynthesized(KnownProtocolKind::Actor); - if (classDecl->isDistributedActor()) - addSynthesized(KnownProtocolKind::DistributedActor); } } diff --git a/lib/AST/TypeCheckRequests.cpp b/lib/AST/TypeCheckRequests.cpp index 088acc35db2..1008541474d 100644 --- a/lib/AST/TypeCheckRequests.cpp +++ b/lib/AST/TypeCheckRequests.cpp @@ -1084,12 +1084,6 @@ void swift::simple_display(llvm::raw_ostream &out, case ImplicitMemberAction::ResolveDecodable: out << "resolve Decodable.init(from:)"; break; - case ImplicitMemberAction::ResolveDistributedActor: - out << "resolve DistributedActor[init(transport:), init(resolve:using:)]"; - break; - case ImplicitMemberAction::ResolveDistributedActorAddress: - out << "resolve DistributedActor[actorAddress]"; - break; } } @@ -1517,7 +1511,6 @@ void CustomAttrTypeRequest::cacheResult(Type value) const { bool ActorIsolation::requiresSubstitution() const { switch (kind) { case ActorInstance: - case DistributedActorInstance: case Independent: case Unspecified: return false; @@ -1532,7 +1525,6 @@ bool ActorIsolation::requiresSubstitution() const { ActorIsolation ActorIsolation::subst(SubstitutionMap subs) const { switch (kind) { case ActorInstance: - case DistributedActorInstance: case Independent: case Unspecified: return *this; @@ -1552,10 +1544,6 @@ void swift::simple_display( out << "actor-isolated to instance of " << state.getActor()->getName(); break; - case ActorIsolation::DistributedActorInstance: - out << "distributed-actor-isolated to instance of " << state.getActor()->getName(); - break; - case ActorIsolation::Independent: out << "actor-independent"; break; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index df89aa94e78..f86852394f8 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -407,10 +407,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, Opts.EnableExperimentalConcurrency |= Args.hasArg(OPT_enable_experimental_concurrency); - - Opts.EnableExperimentalDistributed |= - Args.hasArg(OPT_enable_experimental_distributed); - Opts.EnableInferPublicSendable |= Args.hasFlag(OPT_enable_infer_public_concurrent_value, OPT_disable_infer_public_concurrent_value, @@ -421,12 +417,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, Opts.DisableImplicitConcurrencyModuleImport |= Args.hasArg(OPT_disable_implicit_concurrency_module_import); - /// experimental distributed also implicitly enables experimental concurrency - Opts.EnableExperimentalDistributed |= - Args.hasArg(OPT_enable_experimental_distributed); - Opts.EnableExperimentalConcurrency |= - Args.hasArg(OPT_enable_experimental_distributed); - Opts.DiagnoseInvalidEphemeralnessAsError |= Args.hasArg(OPT_enable_invalid_ephemeralness_as_error); diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index 8a6b52d6dde..9d6bce0eade 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -780,12 +780,6 @@ bool CompilerInvocation::shouldImportSwiftConcurrency() const { FrontendOptions::ParseInputMode::SwiftModuleInterface; } -bool CompilerInvocation::shouldImportSwiftDistributed() const { - return getLangOptions().EnableExperimentalDistributed && - getFrontendOptions().InputMode != - FrontendOptions::ParseInputMode::SwiftModuleInterface; -} - /// Implicitly import the SwiftOnoneSupport module in non-optimized /// builds. This allows for use of popular specialized functions /// from the standard library, which makes the non-optimized builds diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 42851edcf34..c4c50f614aa 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -2525,10 +2525,6 @@ public: auto isolation = getActorIsolation(const_cast(VD)); switch (isolation.getKind()) { - case ActorIsolation::DistributedActorInstance: { - // TODO: implicitlyThrowing here for distributed - LLVM_FALLTHROUGH; // continue the ActorInstance checks - } case ActorIsolation::ActorInstance: { if (IsCrossActorReference) { implicitlyAsync = true; @@ -4655,7 +4651,6 @@ public: static bool canUseAttributeOnDecl(DeclAttrKind DAK, bool IsInSil, bool IsConcurrencyEnabled, - bool IsDistributedEnabled, Optional DK) { if (DeclAttribute::isUserInaccessible(DAK)) return false; @@ -4667,8 +4662,6 @@ public: return false; if (!IsConcurrencyEnabled && DeclAttribute::isConcurrencyOnly(DAK)) return false; - if (!IsDistributedEnabled && DeclAttribute::isDistributedOnly(DAK)) - return false; if (!DK.hasValue()) return true; return DeclAttribute::canAttributeAppearOnDeclKind(DAK, DK.getValue()); @@ -4687,13 +4680,9 @@ public: } } bool IsConcurrencyEnabled = Ctx.LangOpts.EnableExperimentalConcurrency; - bool IsDistributedEnabled = Ctx.LangOpts.EnableExperimentalDistributed; std::string Description = TargetName.str() + " Attribute"; #define DECL_ATTR(KEYWORD, NAME, ...) \ - if (canUseAttributeOnDecl(DAK_##NAME, IsInSil, \ - IsConcurrencyEnabled, \ - IsDistributedEnabled, \ - DK)) \ + if (canUseAttributeOnDecl(DAK_##NAME, IsInSil, IsConcurrencyEnabled, DK)) \ addDeclAttrKeyword(#KEYWORD, Description); #include "swift/AST/Attr.def" } @@ -5898,8 +5887,7 @@ addKeyword(CodeCompletionResultSink &Sink, StringRef Name, } static void addDeclKeywords(CodeCompletionResultSink &Sink, - bool IsConcurrencyEnabled, - bool IsDistributedEnabled) { + bool IsConcurrencyEnabled) { auto AddDeclKeyword = [&](StringRef Name, CodeCompletionKeywordKind Kind, Optional DAK) { if (Name == "let" || Name == "var") { @@ -5917,11 +5905,6 @@ static void addDeclKeywords(CodeCompletionResultSink &Sink, DeclAttribute::isConcurrencyOnly(*DAK)) return; - // Remove keywords only available when distributed is enabled. - if (DAK.hasValue() && !IsDistributedEnabled && - DeclAttribute::isDistributedOnly(*DAK)) - return; - addKeyword(Sink, Name, Kind); }; @@ -6043,7 +6026,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink, LLVM_FALLTHROUGH; } case CompletionKind::StmtOrExpr: - addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency, Context.LangOpts.EnableExperimentalDistributed); + addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency); addStmtKeywords(Sink, MaybeFuncBody); LLVM_FALLTHROUGH; case CompletionKind::ReturnStmtExpr: @@ -6111,7 +6094,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink, .Default(false); }) != ParsedKeywords.end(); if (!HasDeclIntroducer) { - addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency, Context.LangOpts.EnableExperimentalDistributed); + addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency); addLetVarKeywords(Sink); } break; @@ -6920,7 +6903,7 @@ void CodeCompletionCallbacksImpl::doneParsing() { if (CurDeclContext->isTypeContext()) { // Override completion (CompletionKind::NominalMemberBeginning). - addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency, Context.LangOpts.EnableExperimentalDistributed); + addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency); addLetVarKeywords(Sink); SmallVector ParsedKeywords; CompletionOverrideLookup OverrideLookup(Sink, Context, CurDeclContext, @@ -6928,7 +6911,7 @@ void CodeCompletionCallbacksImpl::doneParsing() { OverrideLookup.getOverrideCompletions(SourceLoc()); } else { // Global completion (CompletionKind::PostfixExprBeginning). - addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency, Context.LangOpts.EnableExperimentalDistributed); + addDeclKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency); addStmtKeywords(Sink, MaybeFuncBody); addSuperKeyword(Sink); addLetVarKeywords(Sink); diff --git a/lib/IRGen/GenBuiltin.cpp b/lib/IRGen/GenBuiltin.cpp index 3117e0dc252..74cca751955 100644 --- a/lib/IRGen/GenBuiltin.cpp +++ b/lib/IRGen/GenBuiltin.cpp @@ -355,29 +355,6 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin, return; } - if (Builtin.ID == BuiltinValueKind::InitializeDistributedRemoteActor) { - auto fn = IGF.IGM.getDistributedActorInitializeRemoteFn(); - auto actor = args.claimNext(); - actor = IGF.Builder.CreateBitCast(actor, IGF.IGM.RefCountedPtrTy); - // init(resolve address, using transport) - auto call = IGF.Builder.CreateCall(fn, { - actor - // TODO: might have to carry `address, transport` depending on how we implement the resolve initializers - }); - call->setCallingConv(IGF.IGM.SwiftCC); - return; - } - - if (Builtin.ID == BuiltinValueKind::DestroyDistributedActor) { - auto fn = IGF.IGM.getDistributedActorDestroyFn(); - auto actor = args.claimNext(); - actor = IGF.Builder.CreateBitCast(actor, IGF.IGM.RefCountedPtrTy); - auto call = IGF.Builder.CreateCall(fn, {actor}); - call->setCallingConv(IGF.IGM.SwiftCC); - call->setDoesNotThrow(); - return; - } - // If this is an LLVM IR intrinsic, lower it to an intrinsic call. const IntrinsicInfo &IInfo = IGF.getSILModule().getIntrinsicInfo(FnId); llvm::Intrinsic::ID IID = IInfo.ID; diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp index ef33cc74474..16f04db6498 100644 --- a/lib/IRGen/GenMeta.cpp +++ b/lib/IRGen/GenMeta.cpp @@ -5159,7 +5159,6 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) { case KnownProtocolKind::Differentiable: case KnownProtocolKind::FloatingPoint: case KnownProtocolKind::Actor: - case KnownProtocolKind::DistributedActor: case KnownProtocolKind::SerialExecutor: case KnownProtocolKind::Sendable: case KnownProtocolKind::UnsafeSendable: diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index e443215e405..935d3be6866 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3541,7 +3541,6 @@ ParserStatus Parser::parseDeclAttributeList(DeclAttributes &Attributes) { // '__consuming' // 'convenience' // 'actor' -// 'distributed' bool Parser::parseDeclModifierList(DeclAttributes &Attributes, SourceLoc &StaticLoc, StaticSpellingKind &StaticSpelling) { diff --git a/lib/SIL/IR/OperandOwnership.cpp b/lib/SIL/IR/OperandOwnership.cpp index 0cc34ef417c..b05300cf5e6 100644 --- a/lib/SIL/IR/OperandOwnership.cpp +++ b/lib/SIL/IR/OperandOwnership.cpp @@ -812,9 +812,6 @@ BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, CancelAsyncTask) BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, InitializeDefaultActor) BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, DestroyDefaultActor) -BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, InitializeDistributedRemoteActor) -BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, DestroyDistributedActor) - // FIXME: Why do these reqiuire a borrowed value at all? BUILTIN_OPERAND_OWNERSHIP(ForwardingBorrow, AutoDiffAllocateSubcontext) BUILTIN_OPERAND_OWNERSHIP(ForwardingBorrow, AutoDiffProjectTopLevelSubcontext) diff --git a/lib/SIL/IR/SILDeclRef.cpp b/lib/SIL/IR/SILDeclRef.cpp index b6f227c0697..b784fba894d 100644 --- a/lib/SIL/IR/SILDeclRef.cpp +++ b/lib/SIL/IR/SILDeclRef.cpp @@ -39,9 +39,6 @@ swift::getMethodDispatch(AbstractFunctionDecl *method) { if (method->hasForcedStaticDispatch()) return MethodDispatch::Static; - if (method->getAttrs().hasAttribute()) - return MethodDispatch::Static; - // Import-as-member declarations are always statically referenced. if (method->isImportAsMember()) return MethodDispatch::Static; @@ -122,12 +119,11 @@ bool swift::requiresForeignEntryPoint(ValueDecl *vd) { } SILDeclRef::SILDeclRef(ValueDecl *vd, SILDeclRef::Kind kind, bool isForeign, - bool isDistributed, AutoDiffDerivativeFunctionIdentifier *derivativeId) - : loc(vd), kind(kind), isForeign(isForeign), isDistributed(isDistributed), - defaultArgIndex(0), pointer(derivativeId) {} + : loc(vd), kind(kind), isForeign(isForeign), defaultArgIndex(0), + pointer(derivativeId) {} -SILDeclRef::SILDeclRef(SILDeclRef::Loc baseLoc, bool asForeign, bool asDistributed) +SILDeclRef::SILDeclRef(SILDeclRef::Loc baseLoc, bool asForeign) : defaultArgIndex(0), pointer((AutoDiffDerivativeFunctionIdentifier *)nullptr) { if (auto *vd = baseLoc.dyn_cast()) { @@ -166,7 +162,6 @@ SILDeclRef::SILDeclRef(SILDeclRef::Loc baseLoc, bool asForeign, bool asDistribut } isForeign = asForeign; - isDistributed = asDistributed; } SILDeclRef::SILDeclRef(SILDeclRef::Loc baseLoc, @@ -202,7 +197,7 @@ ASTContext &SILDeclRef::getASTContext() const { } bool SILDeclRef::isThunk() const { - return isForeignToNativeThunk() || isNativeToForeignThunk() || isDistributedThunk(); + return isForeignToNativeThunk() || isNativeToForeignThunk(); } bool SILDeclRef::isClangImported() const { @@ -707,12 +702,6 @@ EffectsKind SILDeclRef::getEffectsAttribute() const { return MA->getKind(); } -bool SILDeclRef::isAnyThunk() const { - return isForeignToNativeThunk() || - isNativeToForeignThunk() || - isDistributedThunk(); -} - bool SILDeclRef::isForeignToNativeThunk() const { // If this isn't a native entry-point, it's not a foreign-to-native thunk. if (isForeign) @@ -758,12 +747,6 @@ bool SILDeclRef::isNativeToForeignThunk() const { llvm_unreachable("Unhandled case in switch"); } -bool SILDeclRef::isDistributedThunk() const { - if (!isDistributed) - return false; - return kind == Kind::Func; -} - /// Use the Clang importer to mangle a Clang declaration. static void mangleClangDecl(raw_ostream &buffer, const clang::NamedDecl *clangDecl, @@ -842,8 +825,6 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const { SKind = ASTMangler::SymbolKind::SwiftAsObjCThunk; } else if (isForeignToNativeThunk()) { SKind = ASTMangler::SymbolKind::ObjCAsSwiftThunk; - } else if (isDistributedThunk()) { - SKind = ASTMangler::SymbolKind::DistributedThunk; } break; case SILDeclRef::ManglingKind::DynamicThunk: @@ -860,7 +841,8 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const { // Use the SILGen name only for the original non-thunked, non-curried entry // point. if (auto NameA = getDecl()->getAttrs().getAttribute()) - if (!NameA->Name.empty() && !isAnyThunk()) { + if (!NameA->Name.empty() && + !isForeignToNativeThunk() && !isNativeToForeignThunk()) { return NameA->Name.str(); } @@ -970,8 +952,6 @@ bool SILDeclRef::requiresNewVTableEntry() const { return true; if (!hasDecl()) return false; - if (isDistributedThunk()) - return false; auto fnDecl = dyn_cast(getDecl()); if (!fnDecl) return false; @@ -1004,10 +984,6 @@ SILDeclRef SILDeclRef::getNextOverriddenVTableEntry() const { // @NSManaged property, then it won't be in the vtable. if (overridden.getDecl()->hasClangNode()) return SILDeclRef(); - - // Distributed thunks are not in the vtable. - if (isDistributedThunk()) - return SILDeclRef(); // An @objc convenience initializer can be "overridden" in the sense that // its selector is reclaimed by a subclass's convenience init with the @@ -1287,8 +1263,6 @@ bool SILDeclRef::canBeDynamicReplacement() const { // generic class can't be a dynamic replacement. if (isForeign && hasDecl() && getDecl()->isNativeMethodReplacement()) return false; - if (isDistributedThunk()) - return false; if (kind == SILDeclRef::Kind::Destroyer || kind == SILDeclRef::Kind::DefaultArgGenerator) return false; @@ -1305,9 +1279,6 @@ bool SILDeclRef::isDynamicallyReplaceable() const { if (!isForeign && hasDecl() && getDecl()->isNativeMethodReplacement()) return false; - if (isDistributedThunk()) - return false; - if (kind == SILDeclRef::Kind::DefaultArgGenerator) return false; if (isStoredPropertyInitializer() || isPropertyWrapperBackingInitializer()) @@ -1343,9 +1314,6 @@ bool SILDeclRef::isDynamicallyReplaceable() const { } bool SILDeclRef::hasAsync() const { - if (isDistributedThunk()) - return true; - if (hasDecl()) { if (auto afd = dyn_cast(getDecl())) { return afd->hasAsync(); diff --git a/lib/SIL/IR/SILFunctionType.cpp b/lib/SIL/IR/SILFunctionType.cpp index cab94b0f540..bde6968b340 100644 --- a/lib/SIL/IR/SILFunctionType.cpp +++ b/lib/SIL/IR/SILFunctionType.cpp @@ -4305,11 +4305,6 @@ TypeConverter::getLoweredFormalTypes(SILDeclRef constant, if (innerExtInfo.isAsync()) extInfo = extInfo.withAsync(true); - // Distributed thunks are always `async throws` - if (constant.isDistributedThunk()) { - extInfo = extInfo.withAsync(true).withThrows(true); - } - // If this is a C++ constructor, don't add the metatype "self" parameter // because we'll never use it and it will cause problems in IRGen. if (constant.getDecl()->getClangDecl() && diff --git a/lib/SIL/IR/ValueOwnership.cpp b/lib/SIL/IR/ValueOwnership.cpp index 68f007f9199..678be4f096b 100644 --- a/lib/SIL/IR/ValueOwnership.cpp +++ b/lib/SIL/IR/ValueOwnership.cpp @@ -537,8 +537,6 @@ CONSTANT_OWNERSHIP_BUILTIN(Owned, CreateAsyncTaskGroupFuture) CONSTANT_OWNERSHIP_BUILTIN(None, ConvertTaskToJob) CONSTANT_OWNERSHIP_BUILTIN(None, InitializeDefaultActor) CONSTANT_OWNERSHIP_BUILTIN(None, DestroyDefaultActor) -CONSTANT_OWNERSHIP_BUILTIN(None, InitializeDistributedRemoteActor) -CONSTANT_OWNERSHIP_BUILTIN(None, DestroyDistributedActor) CONSTANT_OWNERSHIP_BUILTIN(Owned, AutoDiffCreateLinearMapContext) CONSTANT_OWNERSHIP_BUILTIN(None, AutoDiffProjectTopLevelSubcontext) CONSTANT_OWNERSHIP_BUILTIN(None, AutoDiffAllocateSubcontext) diff --git a/lib/SIL/Parser/ParseSIL.cpp b/lib/SIL/Parser/ParseSIL.cpp index 13c1c99e35e..3c4a4f55251 100644 --- a/lib/SIL/Parser/ParseSIL.cpp +++ b/lib/SIL/Parser/ParseSIL.cpp @@ -1397,7 +1397,7 @@ bool SILParser::parseSILDeclRef(SILDeclRef &Result, if (!P.consumeIf(tok::sil_exclamation)) { // Construct SILDeclRef. - Result = SILDeclRef(VD, Kind, IsObjC, /*distributed=*/false, DerivativeId); + Result = SILDeclRef(VD, Kind, IsObjC, DerivativeId); return false; } @@ -1517,7 +1517,7 @@ bool SILParser::parseSILDeclRef(SILDeclRef &Result, } while (P.consumeIf(tok::period)); // Construct SILDeclRef. - Result = SILDeclRef(VD, Kind, IsObjC, /*distributed=*/false, DerivativeId); + Result = SILDeclRef(VD, Kind, IsObjC, DerivativeId); return false; } diff --git a/lib/SILGen/SILGen.cpp b/lib/SILGen/SILGen.cpp index e50aba7beb8..46bca21e8f4 100644 --- a/lib/SILGen/SILGen.cpp +++ b/lib/SILGen/SILGen.cpp @@ -765,23 +765,6 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) { return; } - if (constant.isDistributedThunk()) { - auto loc = constant.getAsRegularLocation(); - loc.markAutoGenerated(); - auto *dc = loc.getAsDeclContext(); - assert(dc); - - preEmitFunction(constant, f, loc); - PrettyStackTraceSILFunction X("silgen emitDistributedThunk", f); - f->setBare(IsBare); - f->setThunk(IsThunk); - - SILGenFunction(*this, *f, dc).emitDistributedThunk(constant); - - postEmitFunction(constant, f); - return; - } - switch (constant.kind) { case SILDeclRef::Kind::Func: { if (auto *ce = constant.getAbstractClosureExpr()) { @@ -1285,12 +1268,6 @@ void SILGenModule::emitAbstractFuncDecl(AbstractFunctionDecl *AFD) { if (!hasFunction(thunk)) emitNativeToForeignThunk(thunk); } - - if (AFD->isDistributed()) { - auto thunk = SILDeclRef(AFD).asDistributed(); - if (!hasFunction(thunk)) - emitDistributedThunk(thunk); - } } void SILGenModule::emitFunction(FuncDecl *fd) { diff --git a/lib/SILGen/SILGen.h b/lib/SILGen/SILGen.h index b8152b7b5a8..2501521f07c 100644 --- a/lib/SILGen/SILGen.h +++ b/lib/SILGen/SILGen.h @@ -326,9 +326,6 @@ public: /// Emits a thunk from a Swift function to the native Swift convention. void emitNativeToForeignThunk(SILDeclRef thunk); - - /// Emits a thunk from an actor function to a potentially distributed call. - void emitDistributedThunk(SILDeclRef thunk); void preEmitFunction(SILDeclRef constant, SILFunction *F, SILLocation L); void postEmitFunction(SILDeclRef constant, SILFunction *F); diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index 9fb140f6e02..f4803d6b45a 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -1051,12 +1051,7 @@ public: return; } - SILDeclRef constant = SILDeclRef(afd); - if (afd->isDistributed()) { - constant = constant.asDistributed(true); - } else { - constant = constant.asForeign(requiresForeignEntryPoint(afd)); - } + auto constant = SILDeclRef(afd).asForeign(requiresForeignEntryPoint(afd)); auto subs = e->getDeclRef().getSubstitutions(); @@ -1113,14 +1108,9 @@ public: } // Otherwise, we have a statically-dispatched call. - auto constant = SILDeclRef(e->getDecl()); - if (e->getDecl()->getAttrs().hasAttribute()) { - constant = constant.asDistributed(true); - } else { - constant = constant.asForeign( - !isConstructorWithGeneratedAllocatorThunk(e->getDecl()) - && requiresForeignEntryPoint(e->getDecl())); - } + auto constant = SILDeclRef(e->getDecl()) + .asForeign(!isConstructorWithGeneratedAllocatorThunk(e->getDecl()) + && requiresForeignEntryPoint(e->getDecl())); auto captureInfo = SGF.SGM.Types.getLoweredLocalCaptures(constant); if (afd->getDeclContext()->isLocalContext() && @@ -3662,7 +3652,6 @@ class CallEmission { Callee callee; FormalEvaluationScope initialWritebackScope; Optional implicitAsyncIsolation; - bool implicitlyThrows; public: /// Create an emission for a call of the given callee. @@ -3670,8 +3659,7 @@ public: FormalEvaluationScope &&writebackScope) : SGF(SGF), callee(std::move(callee)), initialWritebackScope(std::move(writebackScope)), - implicitAsyncIsolation(None), - implicitlyThrows(false) {} + implicitAsyncIsolation(None) {} /// A factory method for decomposing the apply expr \p e into a call /// emission. @@ -3715,12 +3703,6 @@ public: this->implicitAsyncIsolation = implicitAsyncIsolation; } - /// Sets a flag that indicates whether this call be treated as being - /// implicitly throws, i.e., the call may be delegating to a proxy function - /// which actually is throwing, regardless whether or not the actual target - /// function can throw or not. - void setImplicitlyThrows(bool flag) { implicitlyThrows = flag; } - CleanupHandle applyCoroutine(SmallVectorImpl &yields); RValue apply(SGFContext C = SGFContext()) { @@ -4435,10 +4417,6 @@ RValue SILGenFunction::emitApply(ResultPlanPtr &&resultPlan, assert(F.isAsync() && "cannot hop_to_executor in a non-async func!"); switch (*implicitAsyncIsolation) { - case ActorIsolation::DistributedActorInstance: { - // TODO: if the actor is remote there is no need to hop - LLVM_FALLTHROUGH; - } case ActorIsolation::ActorInstance: breadcrumb = emitHopToTargetActor(loc, *implicitAsyncIsolation, args.back()); @@ -5005,11 +4983,6 @@ RValue SILGenFunction::emitApplyMethod(SILLocation loc, ConcreteDeclRef declRef, // Form the reference to the method. auto callRef = SILDeclRef(call, SILDeclRef::Kind::Func) .asForeign(requiresForeignEntryPoint(declRef.getDecl())); - - if (call->isDistributed()) { - callRef = callRef.asDistributed(true); - } - auto declRefConstant = getConstantInfo(getTypeExpansionContext(), callRef); auto subs = declRef.getSubstitutions(); bool throws = false; diff --git a/lib/SILGen/SILGenBridging.cpp b/lib/SILGen/SILGenBridging.cpp index e618a614df1..1655162c7d7 100644 --- a/lib/SILGen/SILGenBridging.cpp +++ b/lib/SILGen/SILGenBridging.cpp @@ -22,7 +22,6 @@ #include "swift/AST/ForeignErrorConvention.h" #include "swift/AST/GenericEnvironment.h" #include "swift/AST/ModuleLoader.h" -#include "swift/AST/NameLookupRequests.h" #include "swift/AST/ParameterList.h" #include "swift/AST/ProtocolConformance.h" #include "swift/SIL/SILArgument.h" @@ -1953,194 +1952,6 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) { B.createReturn(loc, result); } -void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) { - // Check if actor is local or remote and call respective function - // - // func X_distributedThunk(...) async throws -> T { - // if __isRemoteActor(self) { - // return try await Self.__remote_X(...) - // } else { - // return try await self.X(...) - // } - // } - // - - assert(thunk.isDistributed); - SILDeclRef native = thunk.asDistributed(false); - auto fd = cast(thunk.getDecl()); - - ASTContext &ctx = getASTContext(); - - // Use the same generic environment as the native entry point. - F.setGenericEnvironment(SGM.Types.getConstantGenericEnvironment(native)); - - auto loc = thunk.getAsRegularLocation(); - loc.markAutoGenerated(); - Scope scope(Cleanups, CleanupLocation(loc)); - - auto isRemoteBB = createBasicBlock(); - auto isLocalBB = createBasicBlock(); - auto localErrorBB = createBasicBlock(); - auto remoteErrorBB = createBasicBlock(); - auto localReturnBB = createBasicBlock(); - auto remoteReturnBB = createBasicBlock(); - auto errorBB = createBasicBlock(); - auto returnBB = createBasicBlock(); - - auto methodTy = SGM.Types.getConstantOverrideType(getTypeExpansionContext(), - thunk); - auto derivativeFnSILTy = SILType::getPrimitiveObjectType(methodTy); - auto silFnType = derivativeFnSILTy.castTo(); - SILFunctionConventions fnConv(silFnType, SGM.M); - auto resultType = fnConv.getSILResultType(getTypeExpansionContext()); - - auto *selfDecl = fd->getImplicitSelfDecl(); - - SmallVector params; - - bindParametersForForwarding(fd->getParameters(), params); - bindParameterForForwarding(selfDecl, params); - auto selfValue = ManagedValue::forUnmanaged(params[params.size() - 1]); - auto selfType = selfDecl->getType(); - - // if __isRemoteActor(self) { - // ... - // } else { - // ... - // } - { - auto desc = UnqualifiedLookupDescriptor( - DeclNameRef(ctx.Id___isRemoteActor), - fd->getDeclContext(), fd->getLoc(), UnqualifiedLookupOptions()); - auto lookup = - evaluateOrDefault(ctx.evaluator, UnqualifiedLookupRequest{desc}, {}); - FuncDecl *isRemoteFn = nullptr; - for (const auto &result : lookup) { - // FIXME: Validate this further, because we're assuming the exact type. - if (auto func = dyn_cast(result.getValueDecl())) { - isRemoteFn = func; - break; - } - } - - ManagedValue selfAnyObject = B.createInitExistentialRef(loc, getLoweredType(ctx.getAnyObjectType()), - CanType(selfType), - selfValue, {}); - auto result = emitApplyOfLibraryIntrinsic(loc, isRemoteFn, SubstitutionMap(), - {selfAnyObject}, SGFContext()); - - SILValue isRemoteResult = std::move(result).forwardAsSingleValue(*this, loc); - SILValue isRemoteResultUnwrapped = emitUnwrapIntegerResult(loc, isRemoteResult); - - B.createCondBranch(loc, isRemoteResultUnwrapped, isRemoteBB, isLocalBB); - } - - - // if __isRemoteActor(self) { - // return try await Self._remote_X(...) - // } - { - B.emitBlock(isRemoteBB); - - auto *selfTyDecl = FunctionDC->getParent()->getSelfNominalTypeDecl(); - // FIXME: should this be an llvm_unreachable instead? - assert(selfTyDecl && "distributed function declared outside of actor"); - - auto selfMetatype = getLoweredType(selfTyDecl->getInterfaceType()); - SILValue metatypeValue = B.createMetatype(loc, selfMetatype); - - auto remoteFnDecl = selfTyDecl->lookupDirectRemoteFunc(fd); - assert(remoteFnDecl && "Could not find _remote_ function"); - auto remoteFnRef = SILDeclRef(remoteFnDecl); - - SILGenFunctionBuilder builder(SGM); - auto remoteFnSIL = builder.getOrCreateFunction(loc, remoteFnRef, ForDefinition); - - SILValue remoteFn = B.createFunctionRefFor(loc, remoteFnSIL); - - auto subs = F.getForwardingSubstitutionMap(); - - SmallVector remoteParams(params); - remoteParams.emplace_back(metatypeValue); - - B.createTryApply(loc, remoteFn, subs, remoteParams, remoteReturnBB, remoteErrorBB); - } - - // else { - // return try await self.X(...) - // } - { - B.emitBlock(isLocalBB); - - auto nativeMethodTy = SGM.Types.getConstantOverrideType(getTypeExpansionContext(), - native); - auto nativeFnSILTy = SILType::getPrimitiveObjectType(nativeMethodTy); - auto nativeSilFnType = nativeFnSILTy.castTo(); - - SILValue nativeFn = emitClassMethodRef( - loc, params[params.size() - 1], native, nativeMethodTy); - auto subs = F.getForwardingSubstitutionMap(); - - if (nativeSilFnType->hasErrorResult()) { - B.createTryApply(loc, nativeFn, subs, params, localReturnBB, localErrorBB); - } else { - auto result = B.createApply(loc, nativeFn, subs, params); - B.createBranch(loc, returnBB, {result}); - } - } - - { - B.emitBlock(remoteErrorBB); - SILValue error = remoteErrorBB->createPhiArgument( - fnConv.getSILErrorType(getTypeExpansionContext()), - OwnershipKind::Owned); - - B.createBranch(loc, errorBB, {error}); - } - - { - B.emitBlock(localErrorBB); - SILValue error = localErrorBB->createPhiArgument( - fnConv.getSILErrorType(getTypeExpansionContext()), - OwnershipKind::Owned); - - B.createBranch(loc, errorBB, {error}); - } - - { - B.emitBlock(remoteReturnBB); - SILValue result = remoteReturnBB->createPhiArgument( - resultType, OwnershipKind::Owned); - B.createBranch(loc, returnBB, {result}); - } - - { - B.emitBlock(localReturnBB); - SILValue result = localReturnBB->createPhiArgument( - resultType, OwnershipKind::Owned); - B.createBranch(loc, returnBB, {result}); - } - - // Emit return logic - { - B.emitBlock(returnBB); - SILValue resArg = returnBB->createPhiArgument( - resultType, OwnershipKind::Owned); - B.createReturn(loc, resArg); - } - - // Emit the rethrow logic. - { - B.emitBlock(errorBB); - SILValue error = errorBB->createPhiArgument( - fnConv.getSILErrorType(getTypeExpansionContext()), - OwnershipKind::Owned); - - Cleanups.emitCleanupsForReturn(CleanupLocation(loc), IsForUnwind); - B.createThrow(loc, error); - } -} - static SILValue getThunkedForeignFunctionRef(SILGenFunction &SGF, SILLocation loc, diff --git a/lib/SILGen/SILGenConstructor.cpp b/lib/SILGen/SILGenConstructor.cpp index 5c9d56b13ab..439ec830602 100644 --- a/lib/SILGen/SILGenConstructor.cpp +++ b/lib/SILGen/SILGenConstructor.cpp @@ -657,8 +657,9 @@ void SILGenFunction::emitClassConstructorAllocator(ConstructorDecl *ctor) { B.createReturn(ImplicitReturnLocation(Loc), initedSelfValue); } -static void emitDefaultActorInitialization( - SILGenFunction &SGF, SILLocation loc, ManagedValue self) { +static void emitDefaultActorInitialization(SILGenFunction &SGF, + SILLocation loc, + ManagedValue self) { auto &ctx = SGF.getASTContext(); auto builtinName = ctx.getIdentifier( getBuiltinName(BuiltinValueKind::InitializeDefaultActor)); @@ -669,21 +670,6 @@ static void emitDefaultActorInitialization( { self.borrow(SGF, loc).getValue() }); } -static void emitDistributedRemoteActorInitialization( - SILGenFunction &SGF, SILLocation loc, - ManagedValue self, - bool addressArg, bool transportArg // FIXME: make those real arguments - ) { - auto &ctx = SGF.getASTContext(); - auto builtinName = ctx.getIdentifier( - getBuiltinName(BuiltinValueKind::InitializeDistributedRemoteActor)); - auto resultTy = SGF.SGM.Types.getEmptyTupleType(); - - FullExpr scope(SGF.Cleanups, CleanupLocation(loc)); - SGF.B.createBuiltin(loc, builtinName, resultTy, /*subs*/{}, - { self.borrow(SGF, loc).getValue() }); -} - void SILGenFunction::emitConstructorPrologActorHop( SILLocation loc, Optional maybeIso) { @@ -776,17 +762,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) { if (selfClassDecl->isRootDefaultActor() && !isDelegating) { SILLocation PrologueLoc(selfDecl); PrologueLoc.markAsPrologue(); - - if (selfClassDecl->isDistributedActor() && - ctor->isDistributedActorResolveInit()) { - auto addressArg = false; // TODO: get the address argument - auto transportArg = false; // TODO: get the transport argument - emitDistributedRemoteActorInitialization(*this, PrologueLoc, - selfArg, addressArg, transportArg); - } else { - // is normal (default) actor - emitDefaultActorInitialization(*this, PrologueLoc, selfArg); - } + emitDefaultActorInitialization(*this, PrologueLoc, selfArg); } if (!ctor->hasStubImplementation()) { diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp index ebb6924d561..4b56408d398 100644 --- a/lib/SILGen/SILGenExpr.cpp +++ b/lib/SILGen/SILGenExpr.cpp @@ -2205,7 +2205,6 @@ RValue RValueEmitter::visitMemberRefExpr(MemberRefExpr *e, RValue RValueEmitter::visitDynamicMemberRefExpr(DynamicMemberRefExpr *E, SGFContext C) { assert(!E->isImplicitlyAsync() && "an actor-isolated @objc member?"); - assert(!E->isImplicitlyThrows() && "an distributed-actor-isolated @objc member?"); return SGF.emitDynamicMemberRefExpr(E, C); } @@ -2228,7 +2227,6 @@ RValue RValueEmitter::visitSubscriptExpr(SubscriptExpr *E, SGFContext C) { RValue RValueEmitter::visitDynamicSubscriptExpr( DynamicSubscriptExpr *E, SGFContext C) { assert(!E->isImplicitlyAsync() && "an actor-isolated @objc member?"); - assert(!E->isImplicitlyThrows() && "an distributed-actor-isolated @objc member?"); return SGF.emitDynamicSubscriptExpr(E, C); } diff --git a/lib/SILGen/SILGenFunction.h b/lib/SILGen/SILGenFunction.h index 17e0eac1e95..3822c2a3f17 100644 --- a/lib/SILGen/SILGenFunction.h +++ b/lib/SILGen/SILGenFunction.h @@ -675,9 +675,6 @@ public: /// new task. SILFunction *emitNativeAsyncToForeignThunk(SILDeclRef thunk); - /// Generates a thunk from an actor function - void emitDistributedThunk(SILDeclRef thunk); - /// Generate a nullary function that returns the given value. /// If \p emitProfilerIncrement is set, emit a profiler increment for /// \p value. diff --git a/lib/SILGen/SILGenProlog.cpp b/lib/SILGen/SILGenProlog.cpp index 7f2d47e1f99..29d8a819347 100644 --- a/lib/SILGen/SILGenProlog.cpp +++ b/lib/SILGen/SILGenProlog.cpp @@ -469,7 +469,6 @@ void SILGenFunction::emitProlog(CaptureInfo captureInfo, if (auto destructor = dyn_cast(dc)) { switch (getActorIsolation(destructor)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: return true; case ActorIsolation::GlobalActor: @@ -501,15 +500,10 @@ void SILGenFunction::emitProlog(CaptureInfo captureInfo, dyn_cast_or_null(FunctionDC->getAsDecl())) { auto actorIsolation = getActorIsolation(funcDecl); switch (actorIsolation.getKind()) { - case ActorIsolation::Unspecified: - case ActorIsolation::Independent: - case ActorIsolation::GlobalActorUnsafe: - break; - - case ActorIsolation::DistributedActorInstance: { - // TODO: perhaps here we can emit our special handling to make a message? - LLVM_FALLTHROUGH; - } + case ActorIsolation::Unspecified: + case ActorIsolation::Independent: + case ActorIsolation::GlobalActorUnsafe: + break; case ActorIsolation::ActorInstance: { assert(selfParam && "no self parameter for ActorInstance isolation"); @@ -654,8 +648,7 @@ Optional SILGenFunction::emitExecutor( case ActorIsolation::Independent: return None; - case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: { + case ActorIsolation::ActorInstance: { // "self" here means the actor instance's "self" value. assert(maybeSelf.hasValue() && "actor-instance but no self provided?"); auto self = maybeSelf.getValue(); diff --git a/lib/SILGen/SILGenThunk.cpp b/lib/SILGen/SILGenThunk.cpp index 168386abf65..07474b0b697 100644 --- a/lib/SILGen/SILGenThunk.cpp +++ b/lib/SILGen/SILGenThunk.cpp @@ -103,12 +103,6 @@ void SILGenModule::emitNativeToForeignThunk(SILDeclRef thunk) { emitFunctionDefinition(thunk, getFunction(thunk, ForDefinition)); } -void SILGenModule::emitDistributedThunk(SILDeclRef thunk) { - // Thunks are always emitted by need, so don't need delayed emission. - assert(thunk.isDistributedThunk() && "distributed thunks only"); - emitFunctionDefinition(thunk, getFunction(thunk, ForDefinition)); -} - SILValue SILGenFunction::emitGlobalFunctionRef(SILLocation loc, SILDeclRef constant, SILConstantInfo constantInfo, diff --git a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp index 93f2aa3ddb8..8c68a235f96 100644 --- a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp +++ b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp @@ -2053,18 +2053,6 @@ static void emitDefaultActorDestroy(SILBuilder &B, SILLocation loc, B.createEndBorrow(loc, self); } -static void emitDistributedActorDestroy(SILBuilder &B, SILLocation loc, - SILValue self) { - auto builtinName = B.getASTContext().getIdentifier( - getBuiltinName(BuiltinValueKind::DestroyDistributedActor)); - auto resultTy = B.getModule().Types.getEmptyTupleType(); - - self = B.createBeginBorrow(loc, self); - B.createBuiltin(loc, builtinName, resultTy, /*subs*/{}, - { self }); - B.createEndBorrow(loc, self); -} - void LifetimeChecker::processUninitializedRelease(SILInstruction *Release, bool consumed, SILBasicBlock::iterator InsertPt) { @@ -2120,12 +2108,8 @@ void LifetimeChecker::processUninitializedRelease(SILInstruction *Release, // don't need to track it specially. if (!TheMemory.isDelegatingInit()) { auto classDecl = TheMemory.getASTType().getClassOrBoundGenericClass(); - if (classDecl && classDecl->isRootDefaultActor()) { - if (classDecl->isDistributedActor()) - emitDistributedActorDestroy(B, Loc, Pointer); - else - emitDefaultActorDestroy(B, Loc, Pointer); - } + if (classDecl && classDecl->isRootDefaultActor()) + emitDefaultActorDestroy(B, Loc, Pointer); } // We've already destroyed any instance variables initialized by this diff --git a/lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp b/lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp index 5acbcc1c6d3..44374ff3f36 100644 --- a/lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp +++ b/lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp @@ -178,8 +178,6 @@ static bool isBarrier(SILInstruction *inst) { case BuiltinValueKind::ConvertTaskToJob: case BuiltinValueKind::InitializeDefaultActor: case BuiltinValueKind::DestroyDefaultActor: - case BuiltinValueKind::InitializeDistributedRemoteActor: - case BuiltinValueKind::DestroyDistributedActor: case BuiltinValueKind::BuildOrdinarySerialExecutorRef: case BuiltinValueKind::BuildDefaultActorExecutorRef: case BuiltinValueKind::BuildMainActorExecutorRef: diff --git a/lib/Sema/CMakeLists.txt b/lib/Sema/CMakeLists.txt index 3eb6f1e1bbe..3703050f58b 100644 --- a/lib/Sema/CMakeLists.txt +++ b/lib/Sema/CMakeLists.txt @@ -12,7 +12,6 @@ add_swift_host_library(swiftSema STATIC CSFix.cpp CSDiagnostics.cpp CodeSynthesis.cpp - CodeSynthesisDistributedActor.cpp ConstantnessSemaDiagnostics.cpp Constraint.cpp ConstraintGraph.cpp @@ -20,7 +19,6 @@ add_swift_host_library(swiftSema STATIC ConstraintSystem.cpp DebuggerTestingTransform.cpp DerivedConformanceActor.cpp - DerivedConformanceDistributedActor.cpp DerivedConformanceAdditiveArithmetic.cpp DerivedConformanceCaseIterable.cpp DerivedConformanceCodable.cpp @@ -47,7 +45,6 @@ add_swift_host_library(swiftSema STATIC TypeCheckCircularity.cpp TypeCheckCodeCompletion.cpp TypeCheckConcurrency.cpp - TypeCheckDistributed.cpp TypeCheckConstraints.cpp TypeCheckDecl.cpp TypeCheckDeclObjC.cpp diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index 72f351c7812..0a79e08c92c 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -35,7 +35,6 @@ #include "swift/Sema/ConstraintSystem.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" -#include "CodeSynthesisDistributedActor.cpp" using namespace swift; const bool IsImplicit = true; @@ -227,16 +226,6 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl, ASTContext &ctx) { assert(!decl->hasClangNode()); - // Don't synthesize for distributed actors, they're a bit special. - // - // They have their special inits, and should not get the usual - // default/implicit constructor (i.e. `init()` is illegal for them, as they - // always must have an associated transport - via `init(transport:)` or - // `init(resolve:using:)`). - if (auto clazz = dyn_cast(decl)) - if (clazz->isDistributedActor()) - return nullptr; - SourceLoc Loc = decl->getLoc(); auto accessLevel = AccessLevel::Internal; @@ -1196,16 +1185,14 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) { // If we already added implicit initializers, we're done. if (decl->addedImplicitInitializers()) return; - + if (!shouldAttemptInitializerSynthesis(decl)) { decl->setAddedImplicitInitializers(); return; } - if (auto *classDecl = dyn_cast(decl)) { + if (auto *classDecl = dyn_cast(decl)) addImplicitInheritedConstructorsToClass(classDecl); - addImplicitDistributedActorMembersToClass(classDecl); - } // Force the memberwise and default initializers if the type has them. // FIXME: We need to be more lazy about synthesizing constructors. @@ -1287,18 +1274,6 @@ ResolveImplicitMemberRequest::evaluate(Evaluator &evaluator, (void)evaluateTargetConformanceTo(decodableProto); } break; - case ImplicitMemberAction::ResolveDistributedActor: - case ImplicitMemberAction::ResolveDistributedActorAddress: { - // init(transport:) and init(resolve:using:) may be synthesized as part of - // derived conformance to the DistributedActor protocol. - // If the target should conform to the DistributedActor protocol, check the - // conformance here to attempt synthesis. - TypeChecker::addImplicitConstructors(target); - auto *distributedActorProto = - Context.getProtocol(KnownProtocolKind::DistributedActor); - (void)evaluateTargetConformanceTo(distributedActorProto); - } - break; } return std::make_tuple<>(); } @@ -1452,24 +1427,6 @@ HasDefaultInitRequest::evaluate(Evaluator &evaluator, return areAllStoredPropertiesDefaultInitializable(evaluator, decl); } -bool -HasDistributedActorLocalInitRequest::evaluate(Evaluator &evaluator, - NominalTypeDecl *nominal) const { - if (auto *decl = dyn_cast(nominal)) { - if (!decl->isDistributedActor()) - return false; - - for (auto *member : decl->getMembers()) - if (auto ctor = dyn_cast(member)) - if (ctor->isDistributedActorLocalInit()) - return true; - } - - // areAllStoredPropertiesDefaultInitializable(evaluator, decl); - - return false; -} - /// Synthesizer callback for a function body consisting of "return". static std::pair synthesizeSingleReturnFunctionBody(AbstractFunctionDecl *afd, void *) { @@ -1491,20 +1448,16 @@ SynthesizeDefaultInitRequest::evaluate(Evaluator &evaluator, decl); // Create the default constructor. - if (auto ctor = createImplicitConstructor(decl, + auto ctor = createImplicitConstructor(decl, ImplicitConstructorKind::Default, - ctx)) { + ctx); - // Add the constructor. - decl->addMember(ctor); + // Add the constructor. + decl->addMember(ctor); - // Lazily synthesize an empty body for the default constructor. - ctor->setBodySynthesizer(synthesizeSingleReturnFunctionBody); - return ctor; - } - - // no default init was synthesized - return nullptr; + // Lazily synthesize an empty body for the default constructor. + ctor->setBodySynthesizer(synthesizeSingleReturnFunctionBody); + return ctor; } ValueDecl *swift::getProtocolRequirement(ProtocolDecl *protocol, diff --git a/lib/Sema/CodeSynthesisDistributedActor.cpp b/lib/Sema/CodeSynthesisDistributedActor.cpp deleted file mode 100644 index 6ad70920e9e..00000000000 --- a/lib/Sema/CodeSynthesisDistributedActor.cpp +++ /dev/null @@ -1,576 +0,0 @@ -//===--- CodeSynthesis.cpp - Type Checking for Declarations ---------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#include "CodeSynthesis.h" - -#include "TypeChecker.h" -#include "TypeCheckDecl.h" -#include "TypeCheckObjC.h" -#include "TypeCheckType.h" -#include "swift/AST/ASTPrinter.h" -#include "swift/AST/Availability.h" -#include "swift/AST/Expr.h" -#include "swift/AST/GenericEnvironment.h" -#include "swift/AST/Initializer.h" -#include "swift/AST/ParameterList.h" -#include "swift/AST/PrettyStackTrace.h" -#include "swift/AST/ProtocolConformance.h" -#include "swift/AST/SourceFile.h" -#include "swift/AST/TypeCheckRequests.h" -#include "swift/Basic/Defer.h" -#include "swift/ClangImporter/ClangModule.h" -#include "swift/Sema/ConstraintSystem.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" -#include "DerivedConformances.h" -using namespace swift; - -/******************************************************************************/ -/******************************* INITIALIZERS *********************************/ -/******************************************************************************/ - -// ==== Distributed Actor: Local Initializer ----------------------------------- - -/// Creates a new \c CallExpr representing -/// -/// transport.assignAddress(Self.self) -/// -/// \param C The AST context to create the expression in. -/// \param DC The \c DeclContext to create any decls in. -/// \param base The base expression to make the call on. -/// \param returnType The return type of the call. -/// \param param The parameter to the call. -static CallExpr * -createCall_DistributedActor_transport_assignAddress(ASTContext &C, - DeclContext *DC, - Expr *base, Type returnType, - Type param) { - // (_ actorType:) - auto *paramDecl = new (C) ParamDecl(SourceLoc(), - SourceLoc(), Identifier(), - SourceLoc(), C.Id_actorType, DC); - paramDecl->setImplicit(); - paramDecl->setSpecifier(ParamSpecifier::Default); - paramDecl->setInterfaceType(returnType); - - // transport.assignAddress(_:) expr - auto *paramList = ParameterList::createWithoutLoc(paramDecl); - auto *unboundCall = UnresolvedDotExpr::createImplicit(C, base, - C.Id_assignAddress, - paramList); - - // DC->mapTypeIntoContext(param->getInterfaceType()); - auto *selfTypeExpr = TypeExpr::createImplicit(param, C); - auto *dotSelfTypeExpr = new (C) DotSelfExpr(selfTypeExpr, SourceLoc(), - SourceLoc(), param); - - // Full bound self.assignAddress(Self.self) call - Expr *args[1] = {dotSelfTypeExpr}; - Identifier argLabels[1] = {Identifier()}; - return CallExpr::createImplicit(C, unboundCall, C.AllocateCopy(args), - C.AllocateCopy(argLabels)); -} - - -/// Creates a new \c CallExpr representing -/// -/// transport.actorReady(self) -static CallExpr * -createCall_DistributedActor_transport_actorReady(ASTContext &C, - DeclContext *DC, - Expr *base, Type actorType, - Expr *initalizedSelf) { - // (_ actor:) - auto *paramDecl = new (C) ParamDecl(SourceLoc(), - SourceLoc(), Identifier(), - SourceLoc(), C.Id_actor, DC); - paramDecl->setImplicit(); - paramDecl->setSpecifier(ParamSpecifier::Default); - paramDecl->setInterfaceType(actorType); - - // transport.actorReady(_:) expr - auto *paramList = ParameterList::createWithoutLoc(paramDecl); - auto *unboundCall = UnresolvedDotExpr::createImplicit(C, base, - C.Id_actorReady, - paramList); - - // Full bound transport.actorReady(self) call - Expr *args[1] = {initalizedSelf}; - Identifier argLabels[1] = {Identifier()}; - return CallExpr::createImplicit(C, unboundCall, C.AllocateCopy(args), - C.AllocateCopy(argLabels)); -} - -/// Synthesizes the body of the `init(transport:)` initializer as: -/// -/// ``` -/// init(transport: ActorTransport) -/// self.actorTransport = transport -/// self.actorAddress = try transport.assignAddress(Self.self) -/// } -/// ``` -/// -/// \param initDecl The function decl whose body to synthesize. -static std::pair -createBody_DistributedActor_init_transport(AbstractFunctionDecl *initDecl, void *) { - - auto *funcDC = cast(initDecl); - ASTContext &C = funcDC->getASTContext(); - - SmallVector statements; - - auto transportParam = initDecl->getParameters()->get(0); - auto *transportExpr = new (C) DeclRefExpr(ConcreteDeclRef(transportParam), - DeclNameLoc(), /*Implicit=*/true); - - auto *selfRef = DerivedConformance::createSelfDeclRef(initDecl); - - // ==== `self.actorTransport = transport` - { - // self.actorTransport - auto *varTransportExpr = UnresolvedDotExpr::createImplicit(C, selfRef, - C.Id_actorTransport); - auto *assignTransportExpr = new (C) AssignExpr( - varTransportExpr, SourceLoc(), transportExpr, /*Implicit=*/true); - statements.push_back(assignTransportExpr); - } - - auto selfType = funcDC->getInnermostTypeContext()->getSelfTypeInContext(); - - // ==== `self.actorAddress = transport.assignAddress(Self.self)` - { - // self.actorAddress - auto *varAddressExpr = UnresolvedDotExpr::createImplicit(C, selfRef, - C.Id_actorAddress); - // Bound transport.assignAddress(Self.self) call - auto addressType = C.getActorAddressDecl()->getDeclaredInterfaceType(); - auto *callExpr = createCall_DistributedActor_transport_assignAddress(C, funcDC, - /*base=*/transportExpr, - /*returnType=*/addressType, - /*param=*/selfType); - auto *assignAddressExpr = new (C) AssignExpr( - varAddressExpr, SourceLoc(), callExpr, /*Implicit=*/true); - statements.push_back(assignAddressExpr); - } - - // ---=== Done initializing ===--- - // === `transport.actorReady(self)` - { - // Bound transport.actorReady(self) call - auto selfType = funcDC->getInnermostTypeContext()->getSelfTypeInContext(); - auto *callExpr = createCall_DistributedActor_transport_actorReady(C, funcDC, - /*base=*/transportExpr, - /*actorType=*/selfType, - /*param=*/selfRef); - statements.push_back(callExpr); - } - - auto *body = BraceStmt::create(C, SourceLoc(), statements, SourceLoc(), - /*implicit=*/true); - return { body, /*isTypeChecked=*/false }; -} - -/// Synthesizes the -/// -/// ``` -/// init(transport: ActorTransport) -/// ``` -/// -/// local initializer. -static ConstructorDecl * -createDistributedActor_init_local(ClassDecl *classDecl, - ASTContext &ctx) { - auto &C = ctx; - -// auto conformanceDC = derived.getConformanceContext(); - auto conformanceDC = classDecl; - - // Expected type: (Self) -> (ActorTransport) -> (Self) - // - // Params: (transport transport: ActorTransport) - auto transportType = C.getActorTransportDecl()->getDeclaredInterfaceType(); - auto *transportParamDecl = new (C) ParamDecl( - SourceLoc(), SourceLoc(), C.Id_transport, - SourceLoc(), C.Id_transport, conformanceDC); - transportParamDecl->setImplicit(); - transportParamDecl->setSpecifier(ParamSpecifier::Default); - transportParamDecl->setInterfaceType(transportType); - - auto *paramList = ParameterList::createWithoutLoc(transportParamDecl); - - // Func name: init(transport:) - DeclName name(C, DeclBaseName::createConstructor(), paramList); - - auto *initDecl = - new (C) ConstructorDecl(name, SourceLoc(), - /*Failable=*/false, SourceLoc(), - /*Async=*/false, SourceLoc(), - /*Throws=*/false, SourceLoc(), - paramList, - /*GenericParams=*/nullptr, conformanceDC); - initDecl->setImplicit(); - initDecl->setSynthesized(); - initDecl->setBodySynthesizer(&createBody_DistributedActor_init_transport); - - // This constructor is 'required', all distributed actors MUST invoke it. - auto *reqAttr = new (C) RequiredAttr(/*IsImplicit*/true); - initDecl->getAttrs().add(reqAttr); - - auto *nonIsoAttr = new (C) NonisolatedAttr(/*IsImplicit*/true); - initDecl->getAttrs().add(nonIsoAttr); - - initDecl->copyFormalAccessFrom(classDecl, /*sourceIsParentContext=*/true); - - return initDecl; -} - -// ==== Distributed Actor: Resolve Initializer --------------------------------- - -/// Synthesizes the body for -/// -/// ``` -/// init(resolve address: ActorAddress, using transport: ActorTransport) throws { -/// // TODO: implement calling the transport -/// switch try transport.resolve(address: address, as: Self.self) { -/// case .instance(let instance): -/// self = instance -/// case .makeProxy: -/// // TODO: use RebindSelfInConstructorExpr here? -/// self = <>(address, transport) // TODO: implement this -/// } -/// } -/// ``` -/// -/// \param initDecl The function decl whose body to synthesize. -static std::pair -createDistributedActor_init_resolve_body(AbstractFunctionDecl *initDecl, void *) { - - auto *funcDC = cast(initDecl); - auto &C = funcDC->getASTContext(); - - SmallVector statements; // TODO: how many? - - auto addressParam = initDecl->getParameters()->get(0); - auto *addressExpr = new (C) DeclRefExpr(ConcreteDeclRef(addressParam), - DeclNameLoc(), /*Implicit=*/true); - - auto transportParam = initDecl->getParameters()->get(1); - auto *transportExpr = new (C) DeclRefExpr(ConcreteDeclRef(transportParam), - DeclNameLoc(), /*Implicit=*/true); - - auto *selfRef = DerivedConformance::createSelfDeclRef(initDecl); - - // ==== `self.actorTransport = transport` - auto *varTransportExpr = UnresolvedDotExpr::createImplicit(C, selfRef, - C.Id_actorTransport); - auto *assignTransportExpr = new (C) AssignExpr( - varTransportExpr, SourceLoc(), transportExpr, /*Implicit=*/true); - statements.push_back(assignTransportExpr); - - // ==== `self.actorAddress = transport.assignAddress(Self.self)` - // self.actorAddress - auto *varAddressExpr = UnresolvedDotExpr::createImplicit(C, selfRef, - C.Id_actorAddress); - // TODO implement calling the transport with the address and Self.self - // FIXME: this must be checking with the transport instead - auto *assignAddressExpr = new (C) AssignExpr( - varAddressExpr, SourceLoc(), addressExpr, /*Implicit=*/true); - statements.push_back(assignAddressExpr); - // end-of-FIXME: this must be checking with the transport instead - - auto *body = BraceStmt::create(C, SourceLoc(), statements, SourceLoc(), - /*implicit=*/true); - - return { body, /*isTypeChecked=*/false }; -} - -/// Synthesizes the -/// -/// ``` -/// init(resolve address: ActorAddress, using transport: ActorTransport) throws -/// ``` -/// -/// resolve initializer. -static ConstructorDecl * -createDistributedActor_init_resolve(ClassDecl *classDecl, - ASTContext &ctx) { - auto &C = ctx; - - auto conformanceDC = classDecl; - - // Expected type: (Self) -> (ActorAddress, ActorTransport) -> (Self) - // - // Param: (resolve address: ActorAddress) - auto addressType = C.getActorAddressDecl()->getDeclaredInterfaceType(); - auto *addressParamDecl = new (C) ParamDecl( - SourceLoc(), SourceLoc(), C.Id_resolve, - SourceLoc(), C.Id_address, conformanceDC); - addressParamDecl->setImplicit(); - addressParamDecl->setSpecifier(ParamSpecifier::Default); - addressParamDecl->setInterfaceType(addressType); - - // Param: (using transport: ActorTransport) - auto transportType = C.getActorTransportDecl()->getDeclaredInterfaceType(); - auto *transportParamDecl = new (C) ParamDecl( - SourceLoc(), SourceLoc(), C.Id_using, - SourceLoc(), C.Id_transport, conformanceDC); - transportParamDecl->setImplicit(); - transportParamDecl->setSpecifier(ParamSpecifier::Default); - transportParamDecl->setInterfaceType(transportType); - - auto *paramList = ParameterList::create( - C, - /*LParenLoc=*/SourceLoc(), - /*params=*/{addressParamDecl, transportParamDecl}, - /*RParenLoc=*/SourceLoc() - ); - - // Func name: init(resolve:using:) - DeclName name(C, DeclBaseName::createConstructor(), paramList); - - auto *initDecl = - new (C) ConstructorDecl(name, SourceLoc(), - /*Failable=*/false, SourceLoc(), - /*Async=*/false, SourceLoc(), - /*Throws=*/true, SourceLoc(), - paramList, - /*GenericParams=*/nullptr, conformanceDC); - initDecl->setImplicit(); - initDecl->setSynthesized(); - initDecl->setBodySynthesizer(&createDistributedActor_init_resolve_body); - - // This constructor is 'required', all distributed actors MUST have it. - initDecl->getAttrs().add(new (C) RequiredAttr(/*IsImplicit*/true)); - - auto *nonIsoAttr = new (C) NonisolatedAttr(/*IsImplicit*/true); - initDecl->getAttrs().add(nonIsoAttr); - - initDecl->copyFormalAccessFrom(classDecl, /*sourceIsParentContext=*/true); - - return initDecl; -} - -/// Detects which initializer to create, and does so. -static ConstructorDecl * -createDistributedActorInit(ClassDecl *classDecl, - ConstructorDecl *requirement, - ASTContext &ctx) { - assert(classDecl->isDistributedActor()); - - const auto name = requirement->getName(); - auto argumentNames = name.getArgumentNames(); - - switch (argumentNames.size()) { - case 1: { - if (requirement->isDistributedActorLocalInit()) { - return createDistributedActor_init_local(classDecl, ctx); - } - - break; - } - case 2: { - if (requirement->isDistributedActorResolveInit()) { - return createDistributedActor_init_resolve(classDecl, ctx); - } - - break; - } - } - - return nullptr; -} - -static void collectNonOveriddenDistributedActorInits( - ASTContext& Context, - ClassDecl *actorDecl, - SmallVectorImpl &results) { - assert(actorDecl->isDistributedActor()); - auto protoDecl = Context.getProtocol(KnownProtocolKind::DistributedActor); - -// // Record all of the initializers the actorDecl has implemented. -// llvm::SmallPtrSet overriddenInits; -// for (auto member : actorDecl->getMembers()) -// if (auto ctor = dyn_cast(member)) -// if (!ctor->hasStubImplementation()) -// // if (auto overridden = ctor->getOverriddenDecl()) -// overriddenInits.insert(ctor); -// -// actorDecl->synthesizeSemanticMembersIfNeeded( -// DeclBaseName::createConstructor()); - - NLOptions subOptions = (NL_QualifiedDefault | NL_IgnoreAccessControl); - SmallVector lookupResults; - actorDecl->lookupQualified( - protoDecl, DeclNameRef::createConstructor(), - subOptions, lookupResults); - - for (auto decl : lookupResults) { - // Distributed Actor Constructor - auto daCtor = cast(decl); - -// TODO: Don't require it if overriden -// if (!overriddenInits.count(daCtor)) - results.push_back(daCtor); - } -} - - -/// For a distributed actor, automatically define initializers -/// that match the DistributedActor requirements. -// TODO: inheritance is tricky here? -static void addImplicitDistributedActorConstructors(ClassDecl *decl) { - // Bail out if not a distributed actor definition. - if (!decl->isDistributedActor()) - return; - - for (auto member : decl->getMembers()) { - if (auto ctor = dyn_cast(member)) { - if (ctor->isRecursiveValidation()) - return; - } - } - - decl->setAddedImplicitInitializers(); - - // Check whether the user has defined a designated initializer for this class, - // and whether all of its stored properties have initial values. - auto &ctx = decl->getASTContext(); -// bool foundDesignatedInit = hasUserDefinedDesignatedInit(ctx.evaluator, decl); -// bool defaultInitable = -// areAllStoredPropertiesDefaultInitializable(ctx.evaluator, decl); -// -// // We can't define these overrides if we have any uninitialized -// // stored properties. -// if (!defaultInitable && !foundDesignatedInit) -// return; - - SmallVector nonOverridenCtors; - collectNonOveriddenDistributedActorInits( - ctx, decl, nonOverridenCtors); - - for (auto *daCtor : nonOverridenCtors) { - if (auto ctor = createDistributedActorInit(decl, daCtor, ctx)) { - decl->addMember(ctor); - } - } -} - -/******************************************************************************/ -/******************************** PROPERTIES **********************************/ -/******************************************************************************/ - -// TODO: deduplicate with 'declareDerivedProperty' from DerivedConformance... -std::pair -createStoredProperty(ClassDecl *classDecl, ASTContext &ctx, - VarDecl::Introducer introducer, Identifier name, - Type propertyInterfaceType, Type propertyContextType, - bool isStatic, bool isFinal) { - auto parentDC = classDecl; - - VarDecl *propDecl = new (ctx) - VarDecl(/*IsStatic*/ isStatic, introducer, - SourceLoc(), name, parentDC); - propDecl->setImplicit(); - propDecl->setSynthesized(); - propDecl->copyFormalAccessFrom(classDecl, /*sourceIsParentContext*/ true); - propDecl->setInterfaceType(propertyInterfaceType); - - Pattern *propPat = NamedPattern::createImplicit(ctx, propDecl); - propPat->setType(propertyContextType); - - propPat = TypedPattern::createImplicit(ctx, propPat, propertyContextType); - propPat->setType(propertyContextType); - - auto *pbDecl = PatternBindingDecl::createImplicit( - ctx, StaticSpellingKind::None, propPat, /*InitExpr*/ nullptr, - parentDC); - return {propDecl, pbDecl}; -} - -/// Adds the following, fairly special, properties to each distributed actor: -/// - actorTransport -/// - actorAddress -static void addImplicitDistributedActorStoredProperties(ClassDecl *decl) { - assert(decl->isDistributedActor()); - - auto &C = decl->getASTContext(); - - // ``` - // @_distributedActorIndependent - // let actorAddress: ActorAddress - // ``` - // (no need for @actorIndependent because it is an immutable let) - { - auto propertyType = C.getActorAddressDecl()->getDeclaredInterfaceType(); - - VarDecl *propDecl; - PatternBindingDecl *pbDecl; - std::tie(propDecl, pbDecl) = createStoredProperty( - decl, C, - VarDecl::Introducer::Let, C.Id_actorAddress, - propertyType, propertyType, - /*isStatic=*/false, /*isFinal=*/true); - - // mark as @_distributedActorIndependent, allowing access to it from everywhere - propDecl->getAttrs().add( - new (C) DistributedActorIndependentAttr(/*IsImplicit=*/true)); - - decl->addMember(propDecl); - decl->addMember(pbDecl); - } - - // ``` - // @_distributedActorIndependent - // let actorTransport: ActorTransport - // ``` - // (no need for @actorIndependent because it is an immutable let) - { - auto propertyType = C.getActorTransportDecl()->getDeclaredInterfaceType(); - - VarDecl *propDecl; - PatternBindingDecl *pbDecl; - std::tie(propDecl, pbDecl) = createStoredProperty( - decl, C, - VarDecl::Introducer::Let, C.Id_actorTransport, - propertyType, propertyType, - /*isStatic=*/false, /*isFinal=*/true); - - // mark as @_distributedActorIndependent, allowing access to it from everywhere - propDecl->getAttrs().add( - new (C) DistributedActorIndependentAttr(/*IsImplicit=*/true)); - - decl->addMember(propDecl); - decl->addMember(pbDecl); - } -} - -/******************************************************************************/ -/************************ SYNTHESIS ENTRY POINT *******************************/ -/******************************************************************************/ - -/// Entry point for adding all computed members to a distributed actor decl. -static void addImplicitDistributedActorMembersToClass(ClassDecl *decl) { - // Bail out if not a distributed actor definition. - if (!decl->isDistributedActor()) - return; - - auto &C = decl->getASTContext(); - - if (!C.getLoadedModule(C.Id_Distributed)) { - // seems we're missing the _Distributed module, ask to import it explicitly - decl->diagnose(diag::distributed_actor_needs_explicit_distributed_import); - return; - } - - addImplicitDistributedActorConstructors(decl); - addImplicitDistributedActorStoredProperties(decl); -} diff --git a/lib/Sema/DerivedConformanceDistributedActor.cpp b/lib/Sema/DerivedConformanceDistributedActor.cpp deleted file mode 100644 index 753dc8690af..00000000000 --- a/lib/Sema/DerivedConformanceDistributedActor.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===--- DerivedConformanceActor.cpp - Derived Actor Conformance ----------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file implements implicit derivation of the Actor protocol. -// -//===----------------------------------------------------------------------===// - -#include "CodeSynthesis.h" -#include "DerivedConformances.h" -#include "TypeChecker.h" -#include "TypeCheckConcurrency.h" -#include "swift/AST/NameLookupRequests.h" -#include "swift/AST/ParameterList.h" - -using namespace swift; - -bool DerivedConformance::canDeriveDistributedActor( - NominalTypeDecl *nominal, DeclContext *dc) { - auto classDecl = dyn_cast(nominal); - return classDecl && classDecl->isDistributedActor() && dc == nominal; -} -// ==== ------------------------------------------------------------------------ - -// TODO: remove, this is not actually used nowadays, we do this in CodeSynthesisDistributedActor -ValueDecl *DerivedConformance::deriveDistributedActor(ValueDecl *requirement) { - return nullptr; -} diff --git a/lib/Sema/DerivedConformances.cpp b/lib/Sema/DerivedConformances.cpp index 29fddf151a6..03d3cadfd63 100644 --- a/lib/Sema/DerivedConformances.cpp +++ b/lib/Sema/DerivedConformances.cpp @@ -77,8 +77,6 @@ bool DerivedConformance::derivesProtocolConformance(DeclContext *DC, if (*derivableKind == KnownDerivableProtocolKind::Actor) return canDeriveActor(DC, Nominal); - if (*derivableKind == KnownDerivableProtocolKind::DistributedActor) - return canDeriveDistributedActor(Nominal, DC); if (*derivableKind == KnownDerivableProtocolKind::AdditiveArithmetic) return canDeriveAdditiveArithmetic(Nominal, DC); diff --git a/lib/Sema/DerivedConformances.h b/lib/Sema/DerivedConformances.h index c2789ecd45a..a52e873f689 100644 --- a/lib/Sema/DerivedConformances.h +++ b/lib/Sema/DerivedConformances.h @@ -301,15 +301,7 @@ public: /// Derive a Decodable requirement for a struct type. /// /// \returns the derived member, which will also be added to the type. - ValueDecl *deriveDecodable(ValueDecl *requirement); - - /// Whether we can derive the given DistributedActor requirement in the given context. - static bool canDeriveDistributedActor(NominalTypeDecl *nominal, DeclContext *dc); - - /// Derive a DistributedActor requirement for an distributed actor. - /// - /// \returns the derived member, which will also be added to the type. - ValueDecl *deriveDistributedActor(ValueDecl *requirement); + ValueDecl *deriveDecodable(ValueDecl *requirement); /// Determine if \c Actor can be derived for the given type. static bool canDeriveActor(DeclContext *DC, NominalTypeDecl *NTD); diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 2ecce43263d..375c3ec6f87 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -55,6 +55,14 @@ namespace { assert(!D->hasClangNode() && "Clang importer propagated a bogus attribute"); if (!D->hasClangNode()) { SourceLoc loc = attr->getLocation(); +#ifndef NDEBUG + if (!loc.isValid() && !attr->getAddedByAccessNote()) { + llvm::errs() << "Attribute '"; + attr->print(llvm::errs()); + llvm::errs() << "' has invalid location, failed to diagnose!\n"; + assert(false && "Diagnosing attribute with invalid location"); + } +#endif if (loc.isInvalid()) { loc = D->getLoc(); } @@ -272,8 +280,6 @@ public: void visitTransposeAttr(TransposeAttr *attr); void visitActorAttr(ActorAttr *attr); - void visitDistributedActorAttr(DistributedActorAttr *attr); - void visitDistributedActorIndependentAttr(DistributedActorIndependentAttr *attr); void visitGlobalActorAttr(GlobalActorAttr *attr); void visitAsyncAttr(AsyncAttr *attr); void visitSpawnAttr(SpawnAttr *attr); @@ -2124,8 +2130,8 @@ static void checkSpecializeAttrRequirements(SpecializeAttr *attr, GenericSignature specializedSig, ASTContext &ctx) { bool hadError = false; - auto specializedReqs = specializedSig->requirementsNotSatisfiedBy(originalSig); + auto specializedReqs = specializedSig->requirementsNotSatisfiedBy(originalSig); for (auto specializedReq : specializedReqs) { if (!specializedReq.getFirstType()->is()) { ctx.Diags.diagnose(attr->getLocation(), @@ -5392,55 +5398,6 @@ void AttributeChecker::visitActorAttr(ActorAttr *attr) { (void)classDecl->isActor(); } -void AttributeChecker::visitDistributedActorAttr(DistributedActorAttr *attr) { - auto dc = D->getDeclContext(); - - // distributed can be applied to actor class definitions and async functions - if (auto varDecl = dyn_cast(D)) { - // distributed can not be applied to stored properties - diagnoseAndRemoveAttr(attr, diag::distributed_actor_property); - return; - } - - // distributed can only be declared on an `actor` - if (auto classDecl = dyn_cast(D)) { - if (!classDecl->isActor()) { - diagnoseAndRemoveAttr(attr, diag::distributed_actor_not_actor); - return; - } else { - // good: `distributed actor` - return; - } - } else if (dyn_cast(D) || dyn_cast(D)) { - diagnoseAndRemoveAttr(attr, diag::distributed_actor_func_not_in_distributed_actor); - return; - } - - if (auto funcDecl = dyn_cast(D)) { - // distributed functions must not be static - if (funcDecl->isStatic()) { - diagnoseAndRemoveAttr(attr, diag::distributed_actor_func_static); - return; - } - - // distributed func must be declared inside an distributed actor - if (dc->getSelfClassDecl() && - !dc->getSelfClassDecl()->isDistributedActor()) { - diagnoseAndRemoveAttr(attr, diag::distributed_actor_func_not_in_distributed_actor); - return; - } else if (auto protoDecl = dc->getSelfProtocolDecl()){ - if (!protoDecl->inheritsFromDistributedActor()) { - // TODO: could suggest adding `: DistributedActor` to the protocol as well - diagnoseAndRemoveAttr(attr, diag::distributed_actor_func_not_in_distributed_actor); - return; - } - } else if (dc->getSelfStructDecl() || dc->getSelfEnumDecl()) { - diagnoseAndRemoveAttr(attr, diag::distributed_actor_func_not_in_distributed_actor); - return; - } - } -} - void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) { // 'nonisolated' can be applied to global and static/class variables // that do not have storage. @@ -5476,16 +5433,6 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) { } } -void AttributeChecker::visitDistributedActorIndependentAttr(DistributedActorIndependentAttr *attr) { - /// user-inaccessible _distributedActorIndependent can only be applied to let properties - if (auto var = dyn_cast(D)) { - if (!var->isLet()) { - diagnoseAndRemoveAttr(attr, diag::distributed_actor_independent_property_must_be_let); - return; - } - } -} - void AttributeChecker::visitGlobalActorAttr(GlobalActorAttr *attr) { auto nominal = dyn_cast(D); if (!nominal) diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index 4f2a6f19f2e..ea659007fc0 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -14,7 +14,6 @@ // //===----------------------------------------------------------------------===// #include "TypeCheckConcurrency.h" -#include "TypeCheckDistributed.h" #include "TypeChecker.h" #include "TypeCheckType.h" #include "swift/Strings.h" @@ -25,7 +24,6 @@ #include "swift/AST/NameLookupRequests.h" #include "swift/AST/TypeCheckRequests.h" #include "swift/AST/TypeVisitor.h" -#include "swift/AST/ExistentialLayout.h" using namespace swift; @@ -59,8 +57,6 @@ static bool shouldInferAttributeInContext(const DeclContext *dc) { case FileUnitKind::DWARFModule: return true; } - - return true; } return false; @@ -443,8 +439,6 @@ ActorIsolationRestriction ActorIsolationRestriction::forDeclaration( if (cast(decl)->isLocalCapture()) return forUnrestricted(); - auto isolation = getActorIsolation(cast(decl)); - // 'let' declarations are immutable, so they can be accessed across // actors. bool isAccessibleAcrossActors = false; @@ -463,20 +457,6 @@ ActorIsolationRestriction ActorIsolationRestriction::forDeclaration( if (auto func = dyn_cast(decl)) { if (func->isAsyncContext()) isAccessibleAcrossActors = true; - - if (func->isDistributed()) { - if (auto classDecl = dyn_cast(decl->getDeclContext())) { - if (!classDecl->isDistributedActor()) { - // `distributed func` must only be defined in `distributed actor` - func->diagnose( - diag::distributed_actor_func_defined_outside_of_distributed_actor, - func->getName()); - } - } - - return forDistributedActorSelf(isolation.getActor(), - /*isCrossActor*/ isAccessibleAcrossActors); // TODO: not sure? - } } // Similarly, a computed property or subscript that has an 'async' getter @@ -488,17 +468,12 @@ ActorIsolationRestriction ActorIsolationRestriction::forDeclaration( } // Determine the actor isolation of the given declaration. - switch (isolation) { + switch (auto isolation = getActorIsolation(cast(decl))) { case ActorIsolation::ActorInstance: // Protected actor instance members can only be accessed on 'self'. return forActorSelf(isolation.getActor(), isAccessibleAcrossActors || isa(decl)); - case ActorIsolation::DistributedActorInstance: - // Only distributed functions can be called externally on a distributed actor. - return forDistributedActorSelf(isolation.getActor(), - /*isCrossActor*/ isAccessibleAcrossActors || isa(decl)); - case ActorIsolation::GlobalActorUnsafe: case ActorIsolation::GlobalActor: { // A global-actor-isolated function referenced within an expression @@ -608,9 +583,8 @@ static bool shouldDiagnoseExistingDataRaces(const DeclContext *dc); static bool isSendableClosure( const AbstractClosureExpr *closure, bool forActorIsolation) { if (auto explicitClosure = dyn_cast(closure)) { - if (forActorIsolation && explicitClosure->inheritsActorContext()) { + if (forActorIsolation && explicitClosure->inheritsActorContext()) return false; - } if (explicitClosure->isUnsafeSendable()) return true; @@ -1027,33 +1001,32 @@ namespace { } /// Searches the applyStack from back to front for the inner-most CallExpr - /// and marks that CallExpr as implicitly async. + /// and marks that CallExpr as implicitly async. /// /// NOTE: Crashes if no CallExpr was found. - /// + /// /// For example, for global actor function `curryAdd`, if we have: /// ((curryAdd 1) 2) /// then we want to mark the inner-most CallExpr, `(curryAdd 1)`. /// /// The same goes for calls to member functions, such as calc.add(1, 2), /// aka ((add calc) 1 2), looks like this: - /// + /// /// (call_expr /// (dot_syntax_call_expr /// (declref_expr add) /// (declref_expr calc)) - /// (tuple_expr + /// (tuple_expr /// ...)) /// /// and we reach up to mark the CallExpr. - void markNearestCallAsImplicitly(bool setAsync = false, bool setThrows = false) { + void markNearestCallAsImplicitlyAsync() { assert(applyStack.size() > 0 && "not contained within an Apply?"); const auto End = applyStack.rend(); for (auto I = applyStack.rbegin(); I != End; ++I) if (auto call = dyn_cast(*I)) { - if (setAsync) call->setImplicitlyAsync(true); - if (setThrows) call->setImplicitlyThrows(true); + call->setImplicitlyAsync(true); return; } llvm_unreachable("expected a CallExpr in applyStack!"); @@ -1131,7 +1104,7 @@ namespace { if (auto partialApply = decomposePartialApplyThunk( apply, Parent.getAsExpr())) { if (auto memberRef = findMemberReference(partialApply->fn)) { - // NOTE: partially-applied thunks are never annotated as + // NOTE: partially-applied thunks are never annotated as // implicitly async, regardless of whether they are escaping. checkMemberReference( partialApply->base, memberRef->first, memberRef->second, @@ -1269,7 +1242,6 @@ namespace { if (!isa(fn) && !fn->isAsyncContext()) { switch (getActorIsolation(fn)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: case ActorIsolation::GlobalActor: case ActorIsolation::GlobalActorUnsafe: case ActorIsolation::Independent: @@ -1292,24 +1264,10 @@ namespace { /// Note that the given actor member is isolated. /// @param context is allowed to be null if no context is appropriate. void noteIsolatedActorMember(ValueDecl *decl, Expr *context) { - // detect if it is a distributed actor, to provide better isolation notes - - auto isDistributedActor = false; - if (auto dc = dyn_cast(decl->getDeclContext())) - isDistributedActor = dc->isDistributedActor(); - - // FIXME: Make this diagnostic more sensitive to the isolation context of - // the declaration. - if (isDistributedActor) { - if (dyn_cast(decl)) { - // Distributed actor properties are never accessible externally. - decl->diagnose(diag::distributed_actor_isolated_property); - } else { - // it's a function or subscript - decl->diagnose(diag::distributed_actor_isolated_method_note); - } - } else if (auto func = dyn_cast(decl)) { - func->diagnose(diag::actor_isolated_sync_func, // FIXME: this is emitted wrongly for self.hello() + // FIXME: Make this diagnostic more sensitive to the isolation context + // of the declaration. + if (auto func = dyn_cast(decl)) { + func->diagnose(diag::actor_isolated_sync_func, decl->getDescriptiveKind(), decl->getName()); @@ -1400,8 +1358,7 @@ namespace { break; } case ActorIsolationRestriction::CrossActorSelf: - case ActorIsolationRestriction::ActorSelf: - case ActorIsolationRestriction::DistributedActorSelf: { + case ActorIsolationRestriction::ActorSelf: { if (isPartialApply) { // The partially applied InoutArg is a property of actor. This // can really only happen when the property is a struct with a @@ -1450,7 +1407,6 @@ namespace { // Retrieve the actor isolation of the context. switch (auto isolation = getActorIsolationOfContext(dc)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: case ActorIsolation::Independent: case ActorIsolation::Unspecified: return isolation; @@ -1465,15 +1421,13 @@ namespace { bool isInAsynchronousContext() const { auto dc = getDeclContext(); - if (auto func = dyn_cast(dc)) { + if (auto func = dyn_cast(dc)) return func->isAsyncContext(); - } if (auto closure = dyn_cast(dc)) { if (auto type = closure->getType()) { - if (auto fnType = type->getAs()) { + if (auto fnType = type->getAs()) return fnType->isAsync(); - } } } @@ -1530,7 +1484,7 @@ namespace { if (!isInAsynchronousContext()) return AsyncMarkingResult::SyncContext; - markNearestCallAsImplicitly(/*setAsync=*/true); + markNearestCallAsImplicitlyAsync(); result = AsyncMarkingResult::FoundAsync; } else if (!applyStack.empty()) { @@ -1549,7 +1503,7 @@ namespace { return AsyncMarkingResult::SyncContext; // then this ValueDecl appears as the called value of the ApplyExpr. - markNearestCallAsImplicitly(/*setAsync=*/true); + markNearestCallAsImplicitlyAsync(); result = AsyncMarkingResult::FoundAsync; } } @@ -1568,57 +1522,6 @@ namespace { return result; } - enum ThrowsMarkingResult { - FoundThrows, - NotFound - }; - - ThrowsMarkingResult tryMarkImplicitlyThrows(SourceLoc declLoc, - ConcreteDeclRef concDeclRef, - Expr* context) { - - ValueDecl *decl = concDeclRef.getDecl(); - ThrowsMarkingResult result = ThrowsMarkingResult::NotFound; - - if (llvm::isa_and_nonnull(context)) { - if (auto func = dyn_cast(decl)) { - if (func->isDistributed() && !func->hasThrows()) { - // A distributed function is implicitly throwing if called from - // outside of the actor. - // - // If it already is throwing, no need to mark it implicitly so. - markNearestCallAsImplicitly( - /*setAsync=*/false, /*setThrows=*/true); - result = ThrowsMarkingResult::FoundThrows; - } - } - } else if (!applyStack.empty()) { - // Check our applyStack metadata from the traversal. - // Our goal is to identify whether the actor reference appears - // as the called value of the enclosing ApplyExpr. We cannot simply - // inspect Parent here because of expressions like (callee)() - // and the fact that the reference may be just an argument to an apply - ApplyExpr *apply = applyStack.back(); - Expr *fn = apply->getFn()->getValueProvidingExpr(); - if (auto memberRef = findMemberReference(fn)) { - auto concDecl = memberRef->first; - if (decl == concDecl.getDecl() && !apply->implicitlyThrows()) { - - if (auto func = dyn_cast(decl)) { - if (func->isDistributed() && !func->hasThrows()) { - // then this ValueDecl appears as the called value of the ApplyExpr. - markNearestCallAsImplicitly( - /*setAsync=*/false, /*setThrows=*/true); - result = ThrowsMarkingResult::FoundThrows; - } - } - } - } - } - - return result; - } - /// Check actor isolation for a particular application. bool checkApply(ApplyExpr *apply) { auto fnExprType = apply->getFn()->getType(); @@ -1724,8 +1627,7 @@ namespace { } switch (contextIsolation) { - case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: { + case ActorIsolation::ActorInstance: { auto result = tryMarkImplicitlyAsync(loc, valueRef, context); if (result == AsyncMarkingResult::FoundAsync) return false; @@ -1943,13 +1845,10 @@ namespace { } LLVM_FALLTHROUGH; // otherwise, it's invalid so diagnose it. - case ActorIsolationRestriction::ActorSelf: - case ActorIsolationRestriction::DistributedActorSelf: { + case ActorIsolationRestriction::ActorSelf: { auto decl = concDecl.getDecl(); ctx.Diags.diagnose(component.getLoc(), diag::actor_isolated_keypath_component, - /*isDistributed=*/isolation.getKind() == - ActorIsolationRestriction::DistributedActorSelf, decl->getDescriptiveKind(), decl->getName()); diagnosed = true; break; @@ -1993,7 +1892,6 @@ namespace { case ActorIsolationRestriction::CrossActorSelf: case ActorIsolationRestriction::ActorSelf: - case ActorIsolationRestriction::DistributedActorSelf: llvm_unreachable("non-member reference into an actor"); case ActorIsolationRestriction::GlobalActorUnsafe: @@ -2079,59 +1977,6 @@ namespace { ConcurrentReferenceKind::CrossActor); } - case ActorIsolationRestriction::DistributedActorSelf: { - // distributed actor isolation is more strict; - // we do not allow any property access, or synchronous access at all. - - bool continueToCheckingLocalIsolation = false; - // Must reference distributed actor-isolated state on 'self'. - auto *selfVar = getReferencedSelf(base); - if (!selfVar) { - // invocation on not-'self', is only okey if this is a distributed func - - if (auto func = dyn_cast(member)) { - if (!func->isDistributed()) { - ctx.Diags.diagnose(memberLoc, diag::distributed_actor_isolated_method); - // TODO: offer a fixit to add 'distributed' on the member; how to test fixits? See also https://github.com/apple/swift/pull/35930/files - noteIsolatedActorMember(member, context); - return true; - } - - assert(func->isDistributed()); - tryMarkImplicitlyAsync(memberLoc, memberRef, context); - tryMarkImplicitlyThrows(memberLoc, memberRef, context); - - // distributed func reference, that passes all checks, great! - continueToCheckingLocalIsolation = true; - } // end FuncDecl - - if (!continueToCheckingLocalIsolation) { - // it wasn't a function (including a distributed function), - // so we need to perform some more checks - if (auto var = dyn_cast(member)) { - // @_distributedActorIndependent decls are accessible always, - // regardless of distributed actor-isolation; e.g. actorAddress - if (member->getAttrs().hasAttribute()) - return false; - - // otherwise, no other properties are accessible on a distributed actor - if (!continueToCheckingLocalIsolation) { - ctx.Diags.diagnose( - memberLoc, diag::distributed_actor_isolated_non_self_reference, - member->getDescriptiveKind(), - member->getName()); - noteIsolatedActorMember(member, context); - return true; - } - } - - // TODO: would have to also consider subscripts and other things - } - } // end !selfVar - - return false; - } - case ActorIsolationRestriction::ActorSelf: { // Must reference actor-isolated state on 'self'. auto *selfVar = getReferencedSelf(base); @@ -2162,7 +2007,6 @@ namespace { auto curDC = const_cast(getDeclContext()); switch (auto contextIsolation = getActorIsolationOfContext(curDC)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: { // An escaping partial application of something that is part of // the actor's isolated state is never permitted. if (isEscapingPartialApply) { @@ -2175,11 +2019,9 @@ namespace { } return false; - } - case ActorIsolation::Unspecified: { + case ActorIsolation::Unspecified: return false; - } case ActorIsolation::Independent: { auto result = tryMarkImplicitlyAsync(memberLoc, memberRef, context); @@ -2304,8 +2146,7 @@ namespace { return ClosureActorIsolation::forGlobalActor(globalActorType); } - case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: { + case ActorIsolation::ActorInstance: { SmallVector localCaptures; closure->getCaptureInfo().getLocalCaptures(localCaptures); for (const auto &localCapture : localCaptures) { @@ -2374,103 +2215,12 @@ void swift::checkFunctionActorIsolation(AbstractFunctionDecl *decl) { if (auto body = decl->getBody()) { body->walk(checker); } - if (auto ctor = dyn_cast(decl)) { + if (auto ctor = dyn_cast(decl)) if (auto superInit = ctor->getSuperInitCall()) superInit->walk(checker); - } - if (auto attr = decl->getAttrs().getAttribute()) { - if (auto func = dyn_cast(decl)) { - checkDistributedFunction(func, /*diagnose=*/true); - } - } -} - -/// Some actor constructors are special, so we need to check rules about them. -void swift::checkActorConstructor(ClassDecl *decl, ConstructorDecl *ctor) { - // bail out unless distributed actor, only those have special rules to check here - if (decl->isDistributedActor()) - checkDistributedActorConstructor(decl, ctor); -} - -void swift::checkActorConstructorBody(ClassDecl *classDecl, - ConstructorDecl *ctor, - BraceStmt *body) { - // we only have additional checks for distributed actor initializers - if (!classDecl->isDistributedActor()) - return; - - // our synthesized constructors don't need any of those checks - // (i.e. the resolve/local constructor would not delegate anywhere etc) - if (ctor->isSynthesized()) - return; - - if (ctor->isDistributedActorLocalInit() || - ctor->isDistributedActorResolveInit()) { - // it is illegal-to re-declare those explicitly, and this is already diagnosed - // on the decl-level; no need to proceed diagnosing anything about the body here. - return; - } - - // it is convenience initializer, but does it properly delegate to the designated one? - auto initKindAndExpr = ctor->getDelegatingOrChainedInitKind(); - bool isDelegating = initKindAndExpr.initKind == BodyInitKind::Delegating; - - /// the constructor didn't delegate anywhere, but it should have! - if (!isDelegating || - !initKindAndExpr.initExpr || - !initKindAndExpr.initExpr->getFn()) { - // the resolve-initializer of course must never actually delegate to the local one - ctor->diagnose(diag::distributed_actor_init_must_delegate_to_local_init, - ctor->getName()) - .fixItInsert(ctor->getStartLoc(), "self.init(transport: transport)"); // FIXME: how to get better position? - // we're done here, it is not delegating or does delegate anywhere - return; - } - - // we're dealing with a convenience constructor, - // which are required to eventually delegate to init(transport:) - auto fn = initKindAndExpr.initExpr->getFn(); - bool delegatedToLocalInit = false; - bool delegatedToResolveInit = false; - Expr *resolveInitApplyExpr = nullptr; - while (fn && !delegatedToLocalInit && !delegatedToResolveInit) { - if (auto otherCtorRef = dyn_cast(fn)) { - auto otherCtorDecl = otherCtorRef->getDecl(); - if (otherCtorDecl->isDistributedActorLocalInit()) { - delegatedToLocalInit = true; - } else if (otherCtorDecl->isDistributedActorResolveInit()) { - resolveInitApplyExpr = initKindAndExpr.initExpr; - delegatedToResolveInit = true; - } else { - // it delegated to some other constructor; it may still have a chance - // to get it right and eventually delegate to init(transport:), - // so we keep searching. - initKindAndExpr = otherCtorDecl->getDelegatingOrChainedInitKind(); - fn = initKindAndExpr.initExpr ? - initKindAndExpr.initExpr->getFn() : nullptr; - } - } else { - // break out of the loop, seems the constructor didn't delegate to anything next - fn = nullptr; - } - } - if (delegatedToResolveInit) { - assert(resolveInitApplyExpr); - ctor->diagnose(diag::distributed_actor_init_must_not_delegate_to_resolve_init, - ctor->getName()) - .fixItRemove(resolveInitApplyExpr->getSourceRange()); - // fallthrough, suggest that initializers must instead delegate to init(transport:) - } - - if (!delegatedToLocalInit) { - ctor->diagnose(diag::distributed_actor_init_must_delegate_to_local_init, - ctor->getName()) - .fixItInsert(ctor->getStartLoc(), "self.init(transport: transport)"); // FIXME: how to get better position? - } } void swift::checkInitializerActorIsolation(Initializer *init, Expr *expr) { - ActorIsolationChecker checker(init); expr->walk(checker); } @@ -2600,7 +2350,6 @@ static Optional getIsolationFromWitnessedRequirements( auto requirementIsolation = getActorIsolation(requirement); switch (requirementIsolation) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: case ActorIsolation::Unspecified: continue; @@ -2628,7 +2377,6 @@ static Optional getIsolationFromWitnessedRequirements( auto isolation = std::get<1>(isolated); switch (isolation) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: llvm_unreachable("protocol requirements cannot be actor instances"); case ActorIsolation::Independent: @@ -2680,7 +2428,6 @@ static Optional getIsolationFromConformances( nominal->getLocalProtocols(ConformanceLookupKind::NonStructural)) { switch (auto protoIsolation = getActorIsolation(proto)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: case ActorIsolation::Unspecified: case ActorIsolation::Independent: break; @@ -2731,7 +2478,6 @@ static Optional getIsolationFromWrappers( switch (isolation) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: case ActorIsolation::Unspecified: case ActorIsolation::Independent: break; @@ -2830,14 +2576,9 @@ ActorIsolation ActorIsolationRequest::evaluate( // Check for instance members and initializers of actor types, // which are part of actor-isolated state. if (auto nominal = value->getDeclContext()->getSelfNominalTypeDecl()) { - if (nominal->isActor()) { - if (value->isInstanceMember() || isa(value)) { - defaultIsolation = nominal->isDistributedActor() ? - ActorIsolation::forDistributedActorInstance(nominal) : - ActorIsolation::forActorInstance(nominal); - } else if (isa(value)) { - defaultIsolation = ActorIsolation::forActorInstance(nominal); - } + if (nominal->isActor() && + (value->isInstanceMember() || isa(value))) { + defaultIsolation = ActorIsolation::forActorInstance(nominal); } } @@ -2866,13 +2607,6 @@ ActorIsolation ActorIsolationRequest::evaluate( break; } - case ActorIsolation::DistributedActorInstance: { - /// 'distributed actor independent' implies 'actor independent' - if (value->isDistributedActorIndependent()) - value->getAttrs().add( - new (ctx) DistributedActorIndependentAttr(/*IsImplicit=*/true)); - break; - } case ActorIsolation::ActorInstance: case ActorIsolation::Unspecified: if (onlyGlobal) @@ -3059,7 +2793,6 @@ void swift::checkOverrideActorIsolation(ValueDecl *value) { return; case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: // Diagnose below. break; @@ -3083,7 +2816,6 @@ void swift::checkOverrideActorIsolation(ValueDecl *value) { return; case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: case ActorIsolation::Independent: // Diagnose below. break; @@ -3389,7 +3121,6 @@ AnyFunctionType *swift::applyGlobalActorType( Type globalActorType; switch (auto isolation = getActorIsolation(funcOrEnum)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: case ActorIsolation::Independent: case ActorIsolation::Unspecified: return fnType; diff --git a/lib/Sema/TypeCheckConcurrency.h b/lib/Sema/TypeCheckConcurrency.h index a165daf27d6..81c13f6fd1f 100644 --- a/lib/Sema/TypeCheckConcurrency.h +++ b/lib/Sema/TypeCheckConcurrency.h @@ -25,7 +25,6 @@ namespace swift { class AbstractFunctionDecl; -class ConstructorDecl; class ActorIsolation; class AnyFunctionType; class ASTContext; @@ -52,8 +51,6 @@ void addAsyncNotes(AbstractFunctionDecl const* func); /// Check actor isolation rules. void checkTopLevelActorIsolation(TopLevelCodeDecl *decl); void checkFunctionActorIsolation(AbstractFunctionDecl *decl); -void checkActorConstructor(ClassDecl *decl, ConstructorDecl *ctor); -void checkActorConstructorBody(ClassDecl *decl, ConstructorDecl *ctor, BraceStmt *body); void checkInitializerActorIsolation(Initializer *init, Expr *expr); void checkEnumElementActorIsolation(EnumElementDecl *element, Expr *expr); void checkPropertyWrapperActorIsolation( @@ -102,10 +99,6 @@ public: /// are permitted from elsewhere as a cross-actor reference, but /// contexts with unspecified isolation won't diagnose anything. GlobalActorUnsafe, - - /// References to declarations that are part of a distributed actor are - /// only permitted if they are async. - DistributedActorSelf, }; private: @@ -135,9 +128,7 @@ public: /// Retrieve the actor type that the declaration is within. NominalTypeDecl *getActorType() const { - assert(kind == ActorSelf || - kind == CrossActorSelf || - kind == DistributedActorSelf); + assert(kind == ActorSelf || kind == CrossActorSelf); return data.actorType; } @@ -167,15 +158,6 @@ public: return result; } - /// Accesses to the given declaration can only be made via the 'self' of - /// the current actor. - static ActorIsolationRestriction forDistributedActorSelf( - NominalTypeDecl *actor, bool isCrossActor) { - ActorIsolationRestriction result(DistributedActorSelf, isCrossActor); - result.data.actorType = actor; - return result; - } - /// Accesses to the given declaration can only be made via this particular /// global actor or is a cross-actor access. static ActorIsolationRestriction forGlobalActor( @@ -251,8 +233,8 @@ enum class SendableCheck { Optional> checkGlobalActorAttributes( SourceLoc loc, DeclContext *dc, ArrayRef attrs); -/// Get the explicit global actor specified for a closure. +/// Get the explicit global actor specified for a closure. Type getExplicitGlobalActor(ClosureExpr *closure); /// Check the correctness of the given Sendable conformance. diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index de0999fcfb0..6a1253e830d 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -445,14 +445,6 @@ InitKindRequest::evaluate(Evaluator &evaluator, ConstructorDecl *decl) const { } } - // the init(transport:) initializer of a distributed actor is special, as - // it ties the actors lifecycle with the transport. As such, it must always - // be invoked by any other initializer, just like a designated initializer. - if (auto clazz = dyn_cast(decl->getDeclContext())) { - if (clazz->isDistributedActor() && decl->isDistributedActorLocalInit()) - return CtorInitializerKind::Designated; - } - if (decl->getDeclContext()->getExtendedProtocolDecl()) { return CtorInitializerKind::Convenience; } diff --git a/lib/Sema/TypeCheckDeclObjC.cpp b/lib/Sema/TypeCheckDeclObjC.cpp index 8584f07c387..2743e6145c3 100644 --- a/lib/Sema/TypeCheckDeclObjC.cpp +++ b/lib/Sema/TypeCheckDeclObjC.cpp @@ -425,9 +425,6 @@ static bool checkObjCActorIsolation(const ValueDecl *VD, case ActorIsolationRestriction::GlobalActor: // FIXME: Consider whether to limit @objc on global-actor-qualified // declarations. - case ActorIsolationRestriction::DistributedActorSelf: - // we do not allow distributed + objc actors. - return false; case ActorIsolationRestriction::Unrestricted: case ActorIsolationRestriction::Unsafe: return false; @@ -1523,11 +1520,9 @@ bool IsObjCRequest::evaluate(Evaluator &evaluator, ValueDecl *VD) const { // Members of classes can be @objc. isObjC = shouldMarkAsObjC(VD, isa(VD)); } - else if (auto classDecl = dyn_cast(VD)) { + else if (isa(VD)) { // Classes can be @objc. - - // Protocols and enums can also be @objc, but this is covered by the // isObjC() check at the beginning. isObjC = shouldMarkAsObjC(VD, /*allowImplicit=*/false); diff --git a/lib/Sema/TypeCheckDeclOverride.cpp b/lib/Sema/TypeCheckDeclOverride.cpp index 87e231823ef..732c2ffd62f 100644 --- a/lib/Sema/TypeCheckDeclOverride.cpp +++ b/lib/Sema/TypeCheckDeclOverride.cpp @@ -1533,8 +1533,6 @@ namespace { UNINTERESTING_ATTR(ProjectedValueProperty) UNINTERESTING_ATTR(OriginallyDefinedIn) UNINTERESTING_ATTR(Actor) - UNINTERESTING_ATTR(DistributedActor) - UNINTERESTING_ATTR(DistributedActorIndependent) UNINTERESTING_ATTR(GlobalActor) UNINTERESTING_ATTR(Async) UNINTERESTING_ATTR(Spawn) diff --git a/lib/Sema/TypeCheckDeclPrimary.cpp b/lib/Sema/TypeCheckDeclPrimary.cpp index 1166df46f6a..d46556c02a6 100644 --- a/lib/Sema/TypeCheckDeclPrimary.cpp +++ b/lib/Sema/TypeCheckDeclPrimary.cpp @@ -354,13 +354,6 @@ static void installCodingKeysIfNecessary(NominalTypeDecl *NTD) { (void)evaluateOrDefault(NTD->getASTContext().evaluator, req, {}); } -// TODO: same ugly hack as Codable does... -static void installDistributedActorIfNecessary(NominalTypeDecl *NTD) { - auto req = - ResolveImplicitMemberRequest{NTD, ImplicitMemberAction::ResolveDistributedActor}; - (void)evaluateOrDefault(NTD->getASTContext().evaluator, req, {}); -} - // Check for static properties that produce empty option sets // using a rawValue initializer with a value of '0' static void checkForEmptyOptionSet(const VarDecl *VD) { @@ -1408,28 +1401,6 @@ static void maybeDiagnoseClassWithoutInitializers(ClassDecl *classDecl) { diagnoseClassWithoutInitializers(classDecl); } -void TypeChecker::checkResultType(Type resultType, - DeclContext *owner) { -// // Only distributed functions have special requirements on return types. -// if (!owner->isDistributed()) -// return; -// -// auto conformanceDC = owner->getConformanceContext(); -// -// // Result type of distributed functions must be Codable. -// auto target = -// conformanceDC->mapTypeIntoContext(it->second->getValueInterfaceType()); -// if (TypeChecker::conformsToProtocol(target, derived.Protocol, conformanceDC) -// .isInvalid()) { -// TypeLoc typeLoc = { -// it->second->getTypeReprOrParentPatternTypeRepr(), -// it->second->getType(), -// }; -// it->second->diagnose(diag::codable_non_conforming_property_here, -// derived.getProtocolType(), typeLoc); -// propertiesAreValid = false; -} - void TypeChecker::diagnoseDuplicateBoundVars(Pattern *pattern) { SmallVector boundVars; pattern->collectVariables(boundVars); @@ -2219,7 +2190,6 @@ public: TypeChecker::addImplicitConstructors(SD); installCodingKeysIfNecessary(SD); - installDistributedActorIfNecessary(SD); TypeChecker::checkDeclAttributes(SD); @@ -2626,7 +2596,6 @@ public: checkAccessControl(FD); TypeChecker::checkParameterList(FD->getParameters(), FD); - TypeChecker::checkResultType(FD->getResultInterfaceType(), FD); } TypeChecker::checkDeclAttributes(FD); diff --git a/lib/Sema/TypeCheckDistributed.cpp b/lib/Sema/TypeCheckDistributed.cpp deleted file mode 100644 index f657d542558..00000000000 --- a/lib/Sema/TypeCheckDistributed.cpp +++ /dev/null @@ -1,204 +0,0 @@ -//===--- TypeCheckDistributed.cpp - Distributed ---------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file implements type checking support for Swift's concurrency model. -// -//===----------------------------------------------------------------------===// -#include "TypeCheckConcurrency.h" -#include "TypeCheckDistributed.h" -#include "TypeChecker.h" -#include "TypeCheckType.h" -#include "swift/Strings.h" -#include "swift/AST/ASTWalker.h" -#include "swift/AST/Initializer.h" -#include "swift/AST/ParameterList.h" -#include "swift/AST/ProtocolConformance.h" -#include "swift/AST/NameLookupRequests.h" -#include "swift/AST/TypeCheckRequests.h" -#include "swift/AST/TypeVisitor.h" -#include "swift/AST/ExistentialLayout.h" - -using namespace swift; - -// ==== ------------------------------------------------------------------------ - -bool IsDistributedActorRequest::evaluate( - Evaluator &evaluator, NominalTypeDecl *nominal) const { - // Protocols are actors if their `Self` type conforms to `DistributedActor`. - if (auto protocol = dyn_cast(nominal)) { - // Simple case: we have the `DistributedActor` protocol itself. - if (protocol->isSpecificProtocol(KnownProtocolKind::DistributedActor)) - return true; - - auto actorProto = nominal->getASTContext().getProtocol( - KnownProtocolKind::DistributedActor); - if (!actorProto) - return false; - - auto selfType = Type(protocol->getProtocolSelfType()); - auto genericSig = protocol->getGenericSignature(); - if (!genericSig) - return false; - - return genericSig->requiresProtocol(selfType, actorProto); - } - - // Class declarations are 'distributed actors' if they are declared with 'distributed actor' - if(!dyn_cast(nominal)) - return false; - - auto distributedAttr = nominal->getAttrs() - .getAttribute(); - return distributedAttr != nullptr; -} - -bool IsDistributedFuncRequest::evaluate( - Evaluator &evaluator, FuncDecl *func) const { - // Check whether the attribute was explicitly specified. - if (auto attr = func->getAttrs().getAttribute()) { - return true; - } else { - return false; - } -} - -// ==== ------------------------------------------------------------------------ - -/// Check whether the function is a proper distributed function -/// -/// \param diagnose Whether to emit a diagnostic when a problem is encountered. -/// -/// \returns \c true if there was a problem with adding the attribute, \c false -/// otherwise. -bool swift::checkDistributedFunction(FuncDecl *func, bool diagnose) { - // === All parameters and the result type must be Codable - - auto &C = func->getASTContext(); - auto encodableType = C.getProtocol(KnownProtocolKind::Encodable); - auto decodableType = C.getProtocol(KnownProtocolKind::Decodable); - - auto module = func->getParentModule(); - - // --- Check parameters for 'Codable' conformance - for (auto param : *func->getParameters()) { - auto paramType = func->mapTypeIntoContext(param->getInterfaceType()); - if (TypeChecker::conformsToProtocol(paramType, encodableType, module).isInvalid() || - TypeChecker::conformsToProtocol(paramType, decodableType, module).isInvalid()) { - if (diagnose) - func->diagnose( - diag::distributed_actor_func_param_not_codable, - param->getArgumentName().str(), - param->getInterfaceType() - ); - // TODO: suggest a fixit to add Codable to the type? - return true; - } - } - - // --- Result type must be either void or a codable type - auto resultType = func->mapTypeIntoContext(func->getResultInterfaceType()); - if (!resultType->isVoid()) { - if (TypeChecker::conformsToProtocol(resultType, decodableType, module).isInvalid() || - TypeChecker::conformsToProtocol(resultType, encodableType, module).isInvalid()) { - if (diagnose) - func->diagnose( - diag::distributed_actor_func_result_not_codable, - func->getResultInterfaceType() - ); - // TODO: suggest a fixit to add Codable to the type? - return true; - } - } - - // === Each distributed function must have a static _remote_ counterpart - ClassDecl *actorDecl = dyn_cast(func->getParent()); - assert(actorDecl && actorDecl->isDistributedActor()); - - auto remoteFuncDecl = actorDecl->lookupDirectRemoteFunc(func); - if (!remoteFuncDecl) { - if (diagnose) { - auto localFuncName = func->getBaseIdentifier().str().str(); - func->diagnose( - diag::distributed_actor_func_missing_remote_func, - C.getIdentifier("_remote_" + localFuncName)); - } - return true; - } - - if (!remoteFuncDecl->isStatic()) { - if (diagnose) - func->diagnose( - diag::distributed_actor_remote_func_is_not_static, - remoteFuncDecl->getName()); - return true; - } - - if (!remoteFuncDecl->hasAsync() || !remoteFuncDecl->hasThrows()) { - if (diagnose) - func->diagnose( - diag::distributed_actor_remote_func_is_not_async_throws, - remoteFuncDecl->getName()); - return true; - } - - if (remoteFuncDecl->isDistributed()) { - if (diagnose) - func->diagnose( - diag::distributed_actor_remote_func_must_not_be_distributed, - remoteFuncDecl->getName()); - return true; - } - - return false; -} - -void swift::checkDistributedActorConstructor(ClassDecl *decl, ConstructorDecl *ctor) { - // bail out unless distributed actor, only those have special rules to check here - if (!decl->isDistributedActor()) - return; - - // bail out for synthesized constructors - if (ctor->isSynthesized()) - return; - - if (ctor->isDistributedActorLocalInit()) { - // it is not legal to manually define init(transport:) - // TODO: we want to lift this restriction but it is tricky - ctor->diagnose(diag::distributed_actor_local_init_explicitly_defined) - .fixItRemove(SourceRange(ctor->getStartLoc(), decl->getStartLoc())); - // TODO: we should be able to allow this, but then we need to inject - // code or force users to "do the right thing" - return; - } - - if (ctor->isDistributedActorResolveInit()) { - // It is illegal for users to attempt defining a resolve initializer; - // Suggest removing it entirely, there is no way users can implement this init. - ctor->diagnose(diag::distributed_actor_init_resolve_must_not_be_user_defined) - .fixItRemove(SourceRange(ctor->getStartLoc(), decl->getStartLoc())); - return; - } - - // All user defined initializers on distributed actors must be 'convenience'. - // - // The only initializer that is allowed to be designated is init(transport:) - // which we synthesize on behalf of a distributed actor. - // - // When checking ctor bodies we'll check - if (!ctor->isConvenienceInit()) { - ctor->diagnose(diag::distributed_actor_init_user_defined_must_be_convenience, - ctor->getName()) - .fixItInsert(ctor->getConstructorLoc(), "convenience "); - return; - } -} - diff --git a/lib/Sema/TypeCheckDistributed.h b/lib/Sema/TypeCheckDistributed.h deleted file mode 100644 index 7aad46ce05a..00000000000 --- a/lib/Sema/TypeCheckDistributed.h +++ /dev/null @@ -1,58 +0,0 @@ -//===--- TypeCheckDistributed.h - Distributed -------------------*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file provides type checking support for Swift's distributed actor model. -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_SEMA_TYPECHECKDISTRIBUTED_H -#define SWIFT_SEMA_TYPECHECKDISTRIBUTED_H - -#include "swift/AST/ConcreteDeclRef.h" -#include "swift/AST/DiagnosticEngine.h" -#include "swift/AST/Type.h" -#include - -namespace swift { - -class AbstractFunctionDecl; -class ConstructorDecl; -class ActorIsolation; -class AnyFunctionType; -class ASTContext; -class ClassDecl; -class ClosureExpr; -class ConcreteDeclRef; -class CustomAttr; -class Decl; -class DeclContext; -class EnumElementDecl; -class Expr; -class FuncDecl; -class Initializer; -class PatternBindingDecl; -class ProtocolConformance; -class TopLevelCodeDecl; -class TypeBase; -class ValueDecl; - -/// Check distributed actor isolation rules. - -/// The local and resolve distributed actor constructors have special rules to check. -void checkDistributedActorConstructor(ClassDecl *decl, ConstructorDecl *ctor); - -bool checkDistributedFunction(FuncDecl *decl, bool diagnose); - -} - - -#endif /* SWIFT_SEMA_TYPECHECKDISTRIBUTED_H */ diff --git a/lib/Sema/TypeCheckEffects.cpp b/lib/Sema/TypeCheckEffects.cpp index 0fb01e29a19..5020fddd8f5 100644 --- a/lib/Sema/TypeCheckEffects.cpp +++ b/lib/Sema/TypeCheckEffects.cpp @@ -648,8 +648,8 @@ public: ConditionalEffectKind conditionalKind, PotentialEffectReason reason) { Classification result; - for (auto k : kinds) + for (auto k : kinds) result.merge(forEffect(k, conditionalKind, reason)); return result; @@ -774,7 +774,6 @@ public: // If the function doesn't have any effects, we're done here. if (!fnType->isThrowing() && - !E->implicitlyThrows() && !fnType->isAsync() && !E->implicitlyAsync()) { return Classification(); @@ -794,8 +793,8 @@ public: auto classifyApplyEffect = [&](EffectKind kind) { if (!fnType->hasEffect(kind) && - !(kind == EffectKind::Async && E->implicitlyAsync()) && - !(kind == EffectKind::Throws && E->implicitlyThrows())) { + !(kind == EffectKind::Async && + E->implicitlyAsync())) { return; } @@ -2521,7 +2520,7 @@ private: PotentialEffectReason::forPropertyAccess())); } else if (E->isImplicitlyAsync()) { - checkThrowAsyncSite(E, /*requiresTry=*/E->isImplicitlyThrows(), + checkThrowAsyncSite(E, /*requiresTry=*/false, Classification::forUnconditional(EffectKind::Async, PotentialEffectReason::forPropertyAccess())); @@ -2693,7 +2692,7 @@ private: CurContext.diagnoseUnhandledThrowSite(Ctx.Diags, E, isTryCovered, classification.getThrowReason()); } else if (!isTryCovered) { - CurContext.diagnoseUncoveredThrowSite(Ctx, E, // we want this one to trigger + CurContext.diagnoseUncoveredThrowSite(Ctx, E, classification.getThrowReason()); } break; diff --git a/lib/Sema/TypeCheckPropertyWrapper.cpp b/lib/Sema/TypeCheckPropertyWrapper.cpp index d8893edef5c..4320ac54a08 100644 --- a/lib/Sema/TypeCheckPropertyWrapper.cpp +++ b/lib/Sema/TypeCheckPropertyWrapper.cpp @@ -85,7 +85,6 @@ static VarDecl *findValueProperty(ASTContext &ctx, NominalTypeDecl *nominal, // The property must not be isolated to an actor instance. switch (auto isolation = getActorIsolation(var)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: var->diagnose( diag::actor_instance_property_wrapper, var->getName(), nominal->getName()); diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp index 2571a70b730..97e19f6ad9d 100644 --- a/lib/Sema/TypeCheckProtocol.cpp +++ b/lib/Sema/TypeCheckProtocol.cpp @@ -2773,29 +2773,6 @@ bool ConformanceChecker::checkActorIsolation( switch (auto witnessRestriction = ActorIsolationRestriction::forDeclaration( witness, /*fromExpression=*/false)) { - case ActorIsolationRestriction::DistributedActorSelf: { - if (witness->isSynthesized()) { - // Some of our synthesized properties get special treatment, - // they are always available, regardless if the actor is remote even. - auto &C = requirement->getASTContext(); - - // actorAddress is special, it is *always* available. - // even if the actor is 'remote' it is always available and immutable. - if (witness->getName() == C.Id_actorAddress && - witness->getInterfaceType()->isEqual( - C.getActorAddressDecl()->getDeclaredInterfaceType())) - return false; - - // TODO: we don't *really* need to expose the transport like that... reconsider? - if (witness->getName() == C.Id_actorTransport && - witness->getInterfaceType()->isEqual( - C.getActorTransportDecl()->getDeclaredInterfaceType())) - return false; - } - - // continue checking ActorSelf rules - LLVM_FALLTHROUGH; - } case ActorIsolationRestriction::ActorSelf: { // An actor-isolated witness can only conform to an actor-isolated // requirement. @@ -2851,7 +2828,6 @@ bool ConformanceChecker::checkActorIsolation( bool requirementIsUnsafe = false; switch (auto requirementIsolation = getActorIsolation(requirement)) { case ActorIsolation::ActorInstance: - case ActorIsolation::DistributedActorInstance: llvm_unreachable("There are not actor protocols"); case ActorIsolation::GlobalActorUnsafe: @@ -6319,9 +6295,6 @@ ValueDecl *TypeChecker::deriveProtocolRequirement(DeclContext *DC, case KnownDerivableProtocolKind::Differentiable: return derived.deriveDifferentiable(Requirement); - case KnownDerivableProtocolKind::DistributedActor: - return derived.deriveDistributedActor(Requirement); - case KnownDerivableProtocolKind::OptionSet: llvm_unreachable( "When possible, OptionSet is derived via memberwise init synthesis"); diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index f8c36bc2c0e..43063118444 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -1753,9 +1753,6 @@ static void checkClassConstructorBody(ClassDecl *classDecl, ctx.Diags.diagnose(initKindAndExpr.initExpr->getLoc(), diag::delegation_here); } - if (classDecl->isActor()) - checkActorConstructorBody(classDecl, ctor, body); - // An inlinable constructor in a class must always be delegating, // unless the class is '@_fixed_layout'. // Note: This is specifically not using isFormallyResilient. We relax this @@ -1965,7 +1962,7 @@ TypeCheckFunctionBodyRequest::evaluate(Evaluator &evaluator, BraceStmt *body = AFD->getBody(); assert(body && "Expected body to type-check"); - // It's possible we synthesized an already type-checked body, in which case + // It's possible we sythesized an already type-checked body, in which case // we're done. if (AFD->isBodyTypeChecked()) return body; @@ -2046,7 +2043,6 @@ TypeCheckFunctionBodyRequest::evaluate(Evaluator &evaluator, // Class constructor checking. if (auto *ctor = dyn_cast(AFD)) { if (auto classDecl = ctor->getDeclContext()->getSelfClassDecl()) { - checkActorConstructor(classDecl, ctor); checkClassConstructorBody(classDecl, ctor, body); } } diff --git a/lib/Sema/TypeCheckStorage.cpp b/lib/Sema/TypeCheckStorage.cpp index 23685f06ae5..e6690f9eaee 100644 --- a/lib/Sema/TypeCheckStorage.cpp +++ b/lib/Sema/TypeCheckStorage.cpp @@ -121,11 +121,8 @@ static void computeLoweredStoredProperties(NominalTypeDecl *decl) { // If this is an actor, check conformance to the Actor protocol to // ensure that the actor storage will get created (if needed). if (auto classDecl = dyn_cast(decl)) { - // If this is an actor class, check conformance to the Actor protocol to - // ensure that the actor storage will get created (if needed). if (classDecl->isActor()) { ASTContext &ctx = decl->getASTContext(); - if (auto actorProto = ctx.getProtocol(KnownProtocolKind::Actor)) { SmallVector conformances; classDecl->lookupConformance( @@ -133,17 +130,6 @@ static void computeLoweredStoredProperties(NominalTypeDecl *decl) { for (auto conformance : conformances) TypeChecker::checkConformance(conformance->getRootNormalConformance()); } - - // If this is a distributed actor, synthesize its special stored properties. - if (classDecl->isDistributedActor()) { - if (auto actorProto = ctx.getProtocol(KnownProtocolKind::DistributedActor)) { - SmallVector conformances; - classDecl->lookupConformance( - decl->getModuleContext(), actorProto, conformances); - for (auto conformance : conformances) - TypeChecker::checkConformance(conformance->getRootNormalConformance()); - } - } } } } diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h index bf088284a82..a4653095c59 100644 --- a/lib/Sema/TypeChecker.h +++ b/lib/Sema/TypeChecker.h @@ -417,7 +417,6 @@ void addImplicitDynamicAttribute(Decl *D); void checkDeclAttributes(Decl *D); void checkClosureAttributes(ClosureExpr *closure); void checkParameterList(ParameterList *params, DeclContext *owner); -void checkResultType(Type resultType, DeclContext *owner); void diagnoseDuplicateBoundVars(Pattern *pattern); @@ -511,7 +510,7 @@ bool checkContextualRequirements(GenericTypeDecl *decl, DeclContext *dc); /// Add any implicitly-defined constructors required for the given -/// struct, class or actor. +/// struct or class. void addImplicitConstructors(NominalTypeDecl *typeDecl); /// Fold the given sequence expression into an (unchecked) expression diff --git a/lib/TBDGen/TBDGen.cpp b/lib/TBDGen/TBDGen.cpp index 7dd2522b5ba..dab40cb2fa0 100644 --- a/lib/TBDGen/TBDGen.cpp +++ b/lib/TBDGen/TBDGen.cpp @@ -732,10 +732,6 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) { addSymbol(SILDeclRef(AFD).asForeign()); } - if (AFD->isDistributed()) { - addSymbol(SILDeclRef(AFD).asDistributed()); - } - // Add derivative function symbols. for (const auto *differentiableAttr : AFD->getAttrs().getAttributes()) diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake index 7e9148c1026..da301dc867d 100644 --- a/stdlib/cmake/modules/AddSwiftStdlib.cmake +++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake @@ -1650,12 +1650,6 @@ function(add_swift_target_library name) "-Xfrontend;-disable-implicit-concurrency-module-import") endif() - # Turn off implicit import of _Distributed when building libraries - if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED) - list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS - "-Xfrontend;-disable-implicit-distributed-module-import") - endif() - # If we are building this library for targets, loop through the various # SDKs building the variants of this library. list_intersect( diff --git a/stdlib/cmake/modules/SwiftSource.cmake b/stdlib/cmake/modules/SwiftSource.cmake index 6b5be98cdfd..acd0f2470b9 100644 --- a/stdlib/cmake/modules/SwiftSource.cmake +++ b/stdlib/cmake/modules/SwiftSource.cmake @@ -264,10 +264,6 @@ function(_add_target_variant_swift_compile_flags list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY") endif() - if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED) - list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED") - endif() - if(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS) list(APPEND result "-D" "SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS") endif() diff --git a/stdlib/private/StdlibUnittest/CMakeLists.txt b/stdlib/private/StdlibUnittest/CMakeLists.txt index 97a1beed125..4d999311c50 100644 --- a/stdlib/private/StdlibUnittest/CMakeLists.txt +++ b/stdlib/private/StdlibUnittest/CMakeLists.txt @@ -14,9 +14,6 @@ set(swift_stdlib_unittest_link_libraries "") if (SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY) list(APPEND swift_stdlib_unittest_link_libraries "swift_Concurrency") endif() -if (SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED) - list(APPEND swift_stdlib_unittest_link_libraries "swift_Distributed") -endif() add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB # This file should be listed the first. Module name is inferred from the diff --git a/stdlib/public/CMakeLists.txt b/stdlib/public/CMakeLists.txt index d4c4cdf7f48..f32785db299 100644 --- a/stdlib/public/CMakeLists.txt +++ b/stdlib/public/CMakeLists.txt @@ -97,10 +97,6 @@ if(SWIFT_BUILD_STDLIB) if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY) add_subdirectory(Concurrency) endif() - - if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED) - add_subdirectory(Distributed) - endif() endif() if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR) diff --git a/stdlib/public/Concurrency/Actor.cpp b/stdlib/public/Concurrency/Actor.cpp index 4711662f565..df70f11faa2 100644 --- a/stdlib/public/Concurrency/Actor.cpp +++ b/stdlib/public/Concurrency/Actor.cpp @@ -624,7 +624,6 @@ class DefaultActorImpl : public HeapObject { Status_width = 3, HasActiveInlineJob = 3, - IsDistributedRemote = 4, MaxPriority = 8, MaxPriority_width = JobFlags::Priority_width, @@ -655,12 +654,6 @@ class DefaultActorImpl : public HeapObject { FLAGSET_DEFINE_FLAG_ACCESSORS(HasActiveInlineJob, hasActiveInlineJob, setHasActiveInlineJob) - /// Is the actor a distributed 'remote' actor? - /// I.e. it does not have storage for user-defined properties and all - /// function call must be transformed into $distributed_ function calls. - FLAGSET_DEFINE_FLAG_ACCESSORS(IsDistributedRemote, - isDistributedRemote, setIsDistributedRemote) - /// What is the maximum priority of jobs that are currently running /// or enqueued on this actor? /// @@ -688,13 +681,10 @@ class DefaultActorImpl : public HeapObject { }; public: + /// Properly construct an actor, except for the heap header. - /// \param isDistributedRemote When true sets the IsDistributedRemote flag - void initialize(bool isDistributedRemote = false) { - // TODO: this is just a simple implementation, rather we would want to allocate a proxy - auto flags = Flags(); - flags.setIsDistributedRemote(isDistributedRemote); - new (&CurrentState) std::atomic(State{JobRef(), flags}); + void initialize() { + new (&CurrentState) std::atomic(State{JobRef(), Flags()}); } /// Properly destruct an actor, except for the heap header. @@ -717,12 +707,6 @@ public: /// Claim the next job off the actor or give it up. Job *claimNextJobOrGiveUp(bool actorIsOwned, RunningJobInfo runner); - /// Check if the actor is actually a distributed *remote* actor. - /// - /// Note that a distributed *local* actor instance is the same as any other - /// ordinary default (local) actor, and no special handling is needed for them. - bool isDistributedRemote(); - private: void deallocateUnconditional(); @@ -1756,29 +1740,6 @@ void swift::swift_defaultActor_deallocateResilient(HeapObject *actor) { metadata->getInstanceAlignMask()); } -// TODO: most likely where we'd need to create the "proxy instance" instead? -void swift::swift_distributedActor_remote_initialize(DefaultActor *_actor) { // FIXME: !!!!! remove distributed C++ impl not needed? - auto actor = asImpl(_actor); - actor->initialize(/*remote=*/true); -} - -void swift::swift_distributedActor_destroy(DefaultActor *_actor) { // FIXME: !!!!! remove distributed C++ impl not needed? - // TODO: need to resign the address before we destroy: - // something like: actor.transport.resignAddress(actor.address) - - // FIXME: if this is a proxy, we would destroy a bit differently I guess? less memory was allocated etc. - asImpl(_actor)->destroy(); // today we just replicate what defaultActor_destroy does -} - -bool swift::swift_distributed_actor_is_remote(DefaultActor *_actor) { - return asImpl(_actor)->isDistributedRemote(); -} - -/// FIXME: only exists for the quick-and-dirty MainActor implementation. -namespace swift { - Metadata* MainActorMetadata = nullptr; -} - /*****************************************************************************/ /****************************** ACTOR SWITCHING ******************************/ /*****************************************************************************/ @@ -1967,12 +1928,3 @@ static void swift_task_enqueueImpl(Job *job, ExecutorRef executor) { #define OVERRIDE_ACTOR COMPATIBILITY_OVERRIDE #include COMPATIBILITY_OVERRIDE_INCLUDE_PATH - -/*****************************************************************************/ -/***************************** DISTRIBUTED ACTOR *****************************/ -/*****************************************************************************/ - -bool DefaultActorImpl::isDistributedRemote() { - auto state = CurrentState.load(std::memory_order_relaxed); - return state.Flags.isDistributedRemote() == 1; -} diff --git a/stdlib/public/Distributed/CMakeLists.txt b/stdlib/public/Distributed/CMakeLists.txt deleted file mode 100644 index 4955d8a14a1..00000000000 --- a/stdlib/public/Distributed/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -#===--- CMakeLists.txt - Concurrency support library ---------------------===# -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2019 - 2020 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -# -#===----------------------------------------------------------------------===# - -set(swift_distributed_link_libraries - swiftCore) - -add_swift_target_library(swift_Distributed ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB - DistributedActor.swift - - SWIFT_MODULE_DEPENDS_LINUX Glibc - SWIFT_MODULE_DEPENDS_FREEBSD Glibc - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT - - LINK_LIBRARIES ${swift_distributed_link_libraries} - - C_COMPILE_FLAGS - -Dswift_Distributed_EXPORTS - SWIFT_COMPILE_FLAGS - ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} - -parse-stdlib - -Xfrontend -enable-experimental-distributed - LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" - - SWIFT_MODULE_DEPENDS _Concurrency - INSTALL_IN_COMPONENT stdlib -) diff --git a/stdlib/public/Distributed/DistributedActor.swift b/stdlib/public/Distributed/DistributedActor.swift deleted file mode 100644 index 42bda255743..00000000000 --- a/stdlib/public/Distributed/DistributedActor.swift +++ /dev/null @@ -1,270 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2020 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import Swift -import _Concurrency - -/// Common protocol to which all distributed actors conform implicitly. -/// -/// It is not possible to conform to this protocol manually explicitly. -/// Only a 'distributed actor' declaration or protocol with 'DistributedActor' -/// requirement may conform to this protocol. -/// -/// The 'DistributedActor' protocol provides the core functionality of any -/// distributed actor, which involves transforming actor -/// which involves enqueuing new partial tasks to be executed at some -/// point. -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -public protocol DistributedActor: Actor, Codable { - - /// Creates new (local) distributed actor instance, bound to the passed transport. - /// - /// Upon initialization, the `actorAddress` field is populated by the transport, - /// with an address assigned to this actor. - /// - /// - Parameter transport: the transport this distributed actor instance will - /// associated with. - init(transport: ActorTransport) - - /// Resolves the passed in `address` against the `transport`, - /// returning either a local or remote actor reference. - /// - /// The transport will be asked to `resolve` the address and return either - /// a local instance or determine that a proxy instance should be created - /// for this address. A proxy actor will forward all invocations through - /// the transport, allowing it to take over the remote messaging with the - /// remote actor instance. - /// - /// - Parameter address: the address to resolve, and produce an instance or proxy for. - /// - Parameter transport: transport which should be used to resolve the `address`. - init(resolve address: ActorAddress, using transport: ActorTransport) throws - - /// The `ActorTransport` associated with this actor. - /// It is immutable and equal to the transport passed in the local/resolve - /// initializer. - /// - /// Conformance to this requirement is synthesized automatically for any - /// `distributed actor` declaration. - nonisolated var actorTransport: ActorTransport { get } - - /// Logical address which this distributed actor represents. - /// - /// An address is always uniquely pointing at a specific actor instance. - /// - /// Conformance to this requirement is synthesized automatically for any - /// `distributed actor` declaration. - nonisolated var actorAddress: ActorAddress { get } -} - -// ==== Codable conformance ---------------------------------------------------- - -extension CodingUserInfoKey { - @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) - static let actorTransportKey = CodingUserInfoKey(rawValue: "$dist_act_trans")! -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension DistributedActor { - nonisolated public init(from decoder: Decoder) throws { -// guard let transport = decoder.userInfo[.actorTransportKey] as? ActorTransport else { -// throw DistributedActorCodingError(message: -// "ActorTransport not available under the decoder.userInfo") -// } -// -// var container = try decoder.singleValueContainer() -// let address = try container.decode(ActorAddress.self) -// self = try Self(resolve: address, using: transport) // FIXME: This is going to be solved by the init() work!!!! - fatalError("\(#function) is not implemented yet for distributed actors'") - } - - nonisolated public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(self.actorAddress) - } -} -/******************************************************************************/ -/***************************** Actor Transport ********************************/ -/******************************************************************************/ - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -public protocol ActorTransport: Sendable { - /// Resolve a local or remote actor address to a real actor instance, or throw if unable to. - /// The returned value is either a local actor or proxy to a remote actor. - func resolve(address: ActorAddress, as actorType: Act.Type) - throws -> ActorResolved where Act: DistributedActor - - /// Create an `ActorAddress` for the passed actor type. - /// - /// This function is invoked by an distributed actor during its initialization, - /// and the returned address value is stored along with it for the time of its - /// lifetime. - /// - /// The address MUST uniquely identify the actor, and allow resolving it. - /// E.g. if an actor is created under address `addr1` then immediately invoking - /// `transport.resolve(address: addr1, as: Greeter.self)` MUST return a reference - /// to the same actor. - func assignAddress( - _ actorType: Act.Type - ) -> ActorAddress - where Act: DistributedActor - - func actorReady( - _ actor: Act - ) where Act: DistributedActor - - /// Called during actor deinit/destroy. - func resignAddress( - _ address: ActorAddress - ) - -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -public enum ActorResolved { - case resolved(Act) - case makeProxy -} - -/******************************************************************************/ -/***************************** Actor Address **********************************/ -/******************************************************************************/ - -/// Uniquely identifies a distributed actor, and enables sending messages even to remote actors. -/// -/// ## Identity -/// The address is the source of truth with regards to referring to a _specific_ actor in the system. -/// This is in contrast to an `ActorPath` which can be thought of as paths in a filesystem, however without any uniqueness -/// or identity guarantees about the files those paths point to. -/// -/// ## Lifecycle -/// Note, that an ActorAddress is a pure value, and as such does not "participate" in an actors lifecycle; -/// Thus, it may represent an address of an actor that has already terminated, so attempts to locate (resolve) -/// an `ActorRef` for this address may result with a reference to dead letters (meaning, that the actor this address -/// had pointed to does not exist, and most likely is dead / terminated). -/// -/// ## Serialization -/// -/// An address can be serialized using `Codable` or other serialization mechanisms. -/// When shared over the network or with other processes it must include the origin's -/// system address (e.g. the network address of the host, or process identifier). -/// -/// When using `Codable` serialization this is done automatically, by looking up -/// the address of the `ActorTransport` the actor is associated with if was a local -/// instance, or simply carrying the full address if it already was a remote reference. -/// -/// ## Format -/// The address consists of the following parts: -/// -/// ``` -/// | node | path | incarnation | -/// ( protocol | name? | host | port ) ( [segments] name )? ( uint32 ) -/// ``` -/// -/// For example: `sact://human-readable-name@127.0.0.1:7337/user/wallet/id-121242`. -/// Note that the `ActorIncarnation` is not printed by default in the String representation of a path, yet may be inspected on demand. -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -public struct ActorAddress: Codable, Sendable, Equatable, Hashable { - /// Uniquely specifies the actor transport and the protocol used by it. - /// - /// E.g. "xpc", "specific-clustering-protocol" etc. - public var `protocol`: String - - public var host: String? - public var port: Int? - public var nodeID: UInt64? - public var path: String? - - /// Unique Identifier of this actor. - public var uid: UInt64 // TODO: should we remove this - - // FIXME: remove this or implement for real; this is just a hack implementation for now - public init(parse: String) { - self.protocol = "sact" - self.host = "xxx" - self.port = 7337 - self.nodeID = 11 - self.path = "example" - self.uid = 123123 - } -} - -// TODO: naive impl, bring in a real one -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension ActorAddress: CustomStringConvertible { - public var description: String { - var result = `protocol` - result += "://" - if let host = host { - result += host - } - if let port = port { - result += ":\(port)" - } - // TODO: decide if we'd want to print the nodeID too here. - if let path = path { - result += "/\(path)" - } - if uid > 0 { - result += "#\(uid)" - } - return result - } -} - -/******************************************************************************/ -/******************************** Misc ****************************************/ -/******************************************************************************/ - -/// Error protocol to which errors thrown by any `ActorTransport` should conform. -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -public protocol ActorTransportError: Error {} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -public struct DistributedActorCodingError: ActorTransportError { - public let message: String - - public init(message: String) { - self.message = message - } - - public static func missingTransportUserInfo(_ actorType: Act.Type) -> Self - where Act: DistributedActor { - .init(message: "Missing ActorTransport userInfo while decoding") - } -} - -/******************************************************************************/ -/************************* Runtime Functions **********************************/ -/******************************************************************************/ - -// ==== isRemote / isLocal ----------------------------------------------------- - -@_silgen_name("swift_distributed_actor_is_remote") -func __isRemoteActor(_ actor: AnyObject) -> Bool - -func __isLocalActor(_ actor: AnyObject) -> Bool { - return !__isRemoteActor(actor) -} - -// ==== Proxy Actor lifecycle -------------------------------------------------- - -/// Called to initialize the distributed-remote actor 'proxy' instance in an actor. -/// The implementation will call this within the actor's initializer. -@_silgen_name("swift_distributedActor_remote_initialize") -func _distributedActorRemoteInitialize(_ actor: AnyObject) - -/// Called to destroy the default actor instance in an actor. -/// The implementation will call this within the actor's deinit. -/// -/// This will call `actorTransport.resignAddress(self.actorAddress)`. -@_silgen_name("swift_distributedActor_destroy") -func _distributedActorDestroy(_ actor: AnyObject) diff --git a/stdlib/public/SwiftShims/CMakeLists.txt b/stdlib/public/SwiftShims/CMakeLists.txt index fca6f839da0..5ee8a9c9206 100644 --- a/stdlib/public/SwiftShims/CMakeLists.txt +++ b/stdlib/public/SwiftShims/CMakeLists.txt @@ -22,7 +22,6 @@ set(sources UnicodeShims.h Visibility.h _SwiftConcurrency.h - _SwiftDistributed.h CoreMediaOverlayShims.h DispatchOverlayShims.h diff --git a/stdlib/public/SwiftShims/Visibility.h b/stdlib/public/SwiftShims/Visibility.h index 26b4ff37737..deeec91d27d 100644 --- a/stdlib/public/SwiftShims/Visibility.h +++ b/stdlib/public/SwiftShims/Visibility.h @@ -178,11 +178,6 @@ #else #define SWIFT_IMAGE_EXPORTS_swift_Concurrency 0 #endif -#if defined(swift_Distributed_EXPORTS) -#define SWIFT_IMAGE_EXPORTS_swift_Distributed 1 -#else -#define SWIFT_IMAGE_EXPORTS_swift_Distributed 0 -#endif #if defined(swift_Differentiation_EXPORTS) #define SWIFT_IMAGE_EXPORTS_swift_Differentiation 1 #else diff --git a/stdlib/public/SwiftShims/_SwiftDistributed.h b/stdlib/public/SwiftShims/_SwiftDistributed.h deleted file mode 100644 index 280384321a0..00000000000 --- a/stdlib/public/SwiftShims/_SwiftDistributed.h +++ /dev/null @@ -1,29 +0,0 @@ -//===--- _SwiftDistributed.h - Swift Distributed Support --------*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2021 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// Defines types and support functions for the Swift Distributed actors. -// -//===----------------------------------------------------------------------===// -#ifndef SWIFT_DISTRIBUTED_H -#define SWIFT_DISTRIBUTED_H - -#ifdef __cplusplus -namespace swift { -extern "C" { -#endif - -#ifdef __cplusplus -} // extern "C" -} // namespace swift -#endif - -#endif // SWIFT_DISTRIBUTED_H diff --git a/test/AutoDiff/SIL/Parse/sildeclref.sil b/test/AutoDiff/SIL/Parse/sildeclref.sil index 3f5014f0d4b..fdf3e2ee84e 100644 --- a/test/AutoDiff/SIL/Parse/sildeclref.sil +++ b/test/AutoDiff/SIL/Parse/sildeclref.sil @@ -1,4 +1,5 @@ // RUN: %target-sil-opt %s -module-name=sildeclref_parse | %target-sil-opt -module-name=sildeclref_parse | %FileCheck %s + // Parse AutoDiff derivative SILDeclRefs via `witness_method` and `class_method` instructions. import Swift diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7b76447769a..87224f9eca6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -166,7 +166,6 @@ normalize_boolean_spelling(SWIFT_BUILD_SYNTAXPARSERLIB) normalize_boolean_spelling(SWIFT_ENABLE_SOURCEKIT_TESTS) normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING) normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY) -normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED) is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" SWIFT_OPTIMIZED) set(profdata_merge_worker @@ -343,10 +342,6 @@ foreach(SDK ${SWIFT_SDKS}) list(APPEND LIT_ARGS "--param" "concurrency") endif() - if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED) - list(APPEND LIT_ARGS "--param" "distributed") - endif() - foreach(test_subset ${TEST_SUBSETS}) set(directories) set(dependencies ${test_dependencies}) diff --git a/test/Concurrency/Runtime/async.swift b/test/Concurrency/Runtime/async.swift index 0cb53cd1d90..064e2315c71 100644 --- a/test/Concurrency/Runtime/async.swift +++ b/test/Concurrency/Runtime/async.swift @@ -67,3 +67,4 @@ if #available(SwiftStdlib 5.5, *) { } runAllTests() + diff --git a/test/Concurrency/actor_isolation.swift b/test/Concurrency/actor_isolation.swift index b0c6c488b8c..b13b54b3548 100644 --- a/test/Concurrency/actor_isolation.swift +++ b/test/Concurrency/actor_isolation.swift @@ -454,7 +454,7 @@ extension MyActor { _ = await super[0] // Accesses on other actors can only reference immutable data or - // call asynchronous methods + // call asychronous methods _ = otherActor.immutable // okay _ = otherActor.synchronous() // expected-error{{expression is 'async' but is not marked with 'await'}}{{9-9=await }} // expected-note@-1{{calls to instance method 'synchronous()' from outside of its actor context are implicitly asynchronous}} diff --git a/test/Distributed/Runtime/distributed_actor_init_local.swift b/test/Distributed/Runtime/distributed_actor_init_local.swift deleted file mode 100644 index 507337a5f80..00000000000 --- a/test/Distributed/Runtime/distributed_actor_init_local.swift +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s - -// REQUIRES: executable_test -// REQUIRES: concurrency -// REQUIRES: distributed - -// rdar://76038845 -// UNSUPPORTED: use_os_stdlib -// UNSUPPORTED: back_deployment_runtime - -// REQUIRES: radar78290608 - -import _Distributed - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor LocalWorker { -} - -// ==== Fake Transport --------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -struct FakeTransport: ActorTransport { - func resolve(address: ActorAddress, as actorType: Act.Type) - throws -> ActorResolved where Act: DistributedActor { - fatalError() - } - - func assignAddress( - _ actorType: Act.Type - ) -> ActorAddress where Act : DistributedActor { - let address = ActorAddress(parse: "xxx") - print("assign type:\(actorType), address:\(address)") - return address - } - - public func actorReady( - _ actor: Act - ) where Act: DistributedActor { - print("ready actor:\(actor), address:\(actor.actorAddress)") - } - - public func resignAddress( - _ address: ActorAddress - ) { - print("ready address:\(address)") - } -} - -// ==== Execute ---------------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test() { - let transport = FakeTransport() - - _ = LocalWorker(transport: transport) - // CHECK: assign type:LocalWorker, address:[[ADDRESS:.*]] - // CHECK: ready actor:main.LocalWorker, address:[[ADDRESS]] -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -@main struct Main { - static func main() async { - test() - } -} diff --git a/test/Distributed/Runtime/distributed_actor_isRemote.swift b/test/Distributed/Runtime/distributed_actor_isRemote.swift deleted file mode 100644 index 3a8552f4e4a..00000000000 --- a/test/Distributed/Runtime/distributed_actor_isRemote.swift +++ /dev/null @@ -1,91 +0,0 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s --dump-input=always - -// REQUIRES: executable_test -// REQUIRES: concurrency -// REQUIRES: distributed - -// rdar://76038845 -// UNSUPPORTED: use_os_stdlib -// UNSUPPORTED: back_deployment_runtime - -// rdar://77798215 -// UNSUPPORTED: OS=windows-msvc - -// REQUIRES: radar78290608 - -import _Distributed - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor SomeSpecificDistributedActor { - distributed func hello() async throws -> String { - "local impl" - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension SomeSpecificDistributedActor { - static func _remote_hello(actor: SomeSpecificDistributedActor) async throws -> String { - return "remote impl (address: \(actor.actorAddress))" - } -} - -// ==== Fake Transport --------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -struct FakeTransport: ActorTransport { - func resolve(address: ActorAddress, as actorType: Act.Type) - throws -> ActorResolved where Act: DistributedActor { - return .makeProxy - } - - func assignAddress( - _ actorType: Act.Type - ) -> ActorAddress where Act : DistributedActor { - ActorAddress(parse: "") - } - - public func actorReady( - _ actor: Act - ) where Act: DistributedActor {} - - public func resignAddress( - _ address: ActorAddress - ) {} -} - -// ==== Execute ---------------------------------------------------------------- - -@_silgen_name("swift_distributed_actor_is_remote") -func __isRemoteActor(_ actor: AnyObject) -> Bool - -func __isLocalActor(_ actor: AnyObject) -> Bool { - return !__isRemoteActor(actor) -} - -// ==== Execute ---------------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_remote() async { - let address = ActorAddress(parse: "") - let transport = FakeTransport() - - let local = SomeSpecificDistributedActor(transport: transport) - _ = local.actorAddress - assert(__isLocalActor(local) == true, "should be local") - assert(__isRemoteActor(local) == false, "should be local") - - // assume it always makes a remote one - let remote = try! SomeSpecificDistributedActor(resolve: address, using: transport) - assert(__isLocalActor(remote) == false, "should be remote") - assert(__isRemoteActor(remote) == true, "should be remote") - - print("done") // CHECK: done -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -@main struct Main { - static func main() async { - await test_remote() - } -} - diff --git a/test/Distributed/Runtime/distributed_actor_remote_functions.swift b/test/Distributed/Runtime/distributed_actor_remote_functions.swift deleted file mode 100644 index 45fceb9c51b..00000000000 --- a/test/Distributed/Runtime/distributed_actor_remote_functions.swift +++ /dev/null @@ -1,190 +0,0 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s --dump-input=always - -// REQUIRES: executable_test -// REQUIRES: concurrency -// REQUIRES: distributed - -// rdar://76038845 -// UNSUPPORTED: use_os_stdlib -// UNSUPPORTED: back_deployment_runtime - -// rdar://77798215 -// UNSUPPORTED: OS=windows-msvc - -// REQUIRES: radar78290608 - -import _Distributed -import _Concurrency - -struct Boom: Error {} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor SomeSpecificDistributedActor { - let state: String = "hi there" - - distributed func helloAsyncThrows() async throws -> String { - "local(\(#function))" - } - - distributed func helloAsync() async -> String { - "local(\(#function))" - } - - distributed func helloThrows() throws -> String { - "local(\(#function))" - } - - distributed func hello() -> String { - "local(\(#function))" - } - - // === errors - - distributed func helloThrowsImplBoom() throws -> String { - throw Boom() - } - - distributed func helloThrowsTransportBoom() throws -> String { - "local(\(#function))" - } - -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension SomeSpecificDistributedActor { - - static func _remote_helloAsyncThrows(actor: SomeSpecificDistributedActor) async throws -> String { - return "remote(\(#function)) (address: \(actor.actorAddress))" - } - - static func _remote_helloAsync(actor: SomeSpecificDistributedActor) async throws -> String { - return "remote(\(#function)) (address: \(actor.actorAddress))" - } - - static func _remote_helloThrows(actor: SomeSpecificDistributedActor) async throws -> String { - return "remote(\(#function)) (address: \(actor.actorAddress))" - } - - static func _remote_hello(actor: SomeSpecificDistributedActor) async throws -> String { - return "remote(\(#function)) (address: \(actor.actorAddress))" - } - - // === errors - - static func _remote_helloThrowsImplBoom(actor: SomeSpecificDistributedActor) async throws -> String { - throw Boom() - } - - static func _remote_helloThrowsTransportBoom(actor: SomeSpecificDistributedActor) async throws -> String { - throw Boom() - } -} - -// ==== Execute ---------------------------------------------------------------- - -@_silgen_name("swift_distributed_actor_is_remote") -func __isRemoteActor(_ actor: AnyObject) -> Bool - -func __isLocalActor(_ actor: AnyObject) -> Bool { - return !__isRemoteActor(actor) -} - -// ==== Fake Transport --------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -struct FakeTransport: ActorTransport { - func resolve(address: ActorAddress, as actorType: Act.Type) - throws -> ActorResolved where Act: DistributedActor { - return .makeProxy - } - - func assignAddress( - _ actorType: Act.Type - ) -> ActorAddress where Act : DistributedActor { - ActorAddress(parse: "") - } - - public func actorReady( - _ actor: Act - ) where Act: DistributedActor {} - - public func resignAddress( - _ address: ActorAddress - ) {} -} - -// ==== Execute ---------------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_remote_invoke(address: ActorAddress, transport: ActorTransport) async { - func check(actor: SomeSpecificDistributedActor) async { - let personality = __isRemoteActor(actor) ? "remote" : "local" - - let h1 = try! await actor.helloAsyncThrows() - print("\(personality) - helloAsyncThrows: \(h1)") - - let h2 = try! await actor.helloAsync() - print("\(personality) - helloAsync: \(h2)") - - let h3 = try! await actor.helloThrows() - print("\(personality) - helloThrows: \(h3)") - - let h4 = try! await actor.hello() - print("\(personality) - hello: \(h4)") - - // error throws - if __isRemoteActor(actor) { - do { - _ = try await actor.helloThrowsTransportBoom() - preconditionFailure("Should have thrown") - } catch { - print("\(personality) - helloThrowsTransportBoom: \(error)") - } - - do { - _ = try await actor.helloThrowsImplBoom() - preconditionFailure("Should have thrown") - } catch { - print("\(personality) - helloThrowsImplBoom: \(error)") - } - } - } - - let remote = try! SomeSpecificDistributedActor(resolve: address, using: transport) - assert(__isRemoteActor(remote) == true, "should be remote") - - let local = SomeSpecificDistributedActor(transport: transport) - assert(__isRemoteActor(local) == false, "should be local") - - print("local isRemote: \(__isRemoteActor(local))") - // CHECK: local isRemote: false - await check(actor: local) - // CHECK: local - helloAsyncThrows: local(helloAsyncThrows()) - // CHECK: local - helloAsync: local(helloAsync()) - // CHECK: local - helloThrows: local(helloThrows()) - // CHECK: local - hello: local(hello()) - - - print("remote isRemote: \(__isRemoteActor(remote))") - // CHECK: remote isRemote: true - await check(actor: remote) - // CHECK: remote - helloAsyncThrows: remote(_remote_helloAsyncThrows(actor:)) - // CHECK: remote - helloAsync: remote(_remote_helloAsync(actor:)) - // CHECK: remote - helloThrows: remote(_remote_helloThrows(actor:)) - // CHECK: remote - hello: remote(_remote_hello(actor:)) - // CHECK: remote - helloThrowsTransportBoom: Boom() - // CHECK: remote - helloThrowsImplBoom: Boom() - - print(local) - print(remote) -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -@main struct Main { - static func main() async { - let address = ActorAddress(parse: "") - let transport = FakeTransport() - - await test_remote_invoke(address: address, transport: transport) - } -} diff --git a/test/Distributed/Runtime/distributed_actor_run.swift b/test/Distributed/Runtime/distributed_actor_run.swift deleted file mode 100644 index 7d97269c072..00000000000 --- a/test/Distributed/Runtime/distributed_actor_run.swift +++ /dev/null @@ -1,96 +0,0 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s - -// REQUIRES: executable_test -// REQUIRES: concurrency -// REQUIRES: distributed - -// rdar://76038845 -// UNSUPPORTED: use_os_stdlib -// UNSUPPORTED: back_deployment_runtime - -// REQUIRES: radar78290608 - -import _Distributed - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor SomeSpecificDistributedActor { - - distributed func hello() async throws { - print("hello from \(self.actorAddress)") - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension SomeSpecificDistributedActor { - static func _remote_hello(actor: SomeSpecificDistributedActor) async throws { - print("Remote invocation") - } -} - -// ==== Execute ---------------------------------------------------------------- - -@_silgen_name("swift_distributed_actor_is_remote") -func __isRemoteActor(_ actor: AnyObject) -> Bool - -func __isLocalActor(_ actor: AnyObject) -> Bool { - return !__isRemoteActor(actor) -} - - -// ==== Fake Transport --------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -struct FakeTransport: ActorTransport { - func resolve(address: ActorAddress, as actorType: Act.Type) - throws -> ActorResolved where Act: DistributedActor { - fatalError() - } - func assignAddress( - _ actorType: Act.Type - ) -> ActorAddress where Act : DistributedActor { - ActorAddress(parse: "") - } - - public func actorReady( - _ actor: Act - ) where Act: DistributedActor {} - - public func resignAddress( - _ address: ActorAddress - ) {} -} - -// ==== Execute ---------------------------------------------------------------- - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_initializers() { - let address = ActorAddress(parse: "") - let transport = FakeTransport() - - _ = SomeSpecificDistributedActor(transport: transport) - _ = try! SomeSpecificDistributedActor(resolve: address, using: transport) -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_address() { - let transport = FakeTransport() - - let actor = SomeSpecificDistributedActor(transport: transport) - _ = actor.actorAddress -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_run(transport: FakeTransport) async { - let actor = SomeSpecificDistributedActor(transport: transport) - - print("before") // CHECK: before - try! await actor.hello() - print("after") // CHECK: after -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -@main struct Main { - static func main() async { - await test_run(transport: FakeTransport()) - } -} diff --git a/test/Distributed/distributed_actor_func_implicitly_async_throws.swift b/test/Distributed/distributed_actor_func_implicitly_async_throws.swift deleted file mode 100644 index 6b2a5ea2e6d..00000000000 --- a/test/Distributed/distributed_actor_func_implicitly_async_throws.swift +++ /dev/null @@ -1,103 +0,0 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-distributed -// REQUIRES: concurrency -// REQUIRES: distributed - -import _Distributed - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor D { - - func hello() {} // expected-note{{only 'distributed' functions can be called from outside the distributed actor}} - func helloAsync() async {} // expected-note{{only 'distributed' functions can be called from outside the distributed actor}} - func helloAsyncThrows() async throws {} // expected-note{{only 'distributed' functions can be called from outside the distributed actor}} - - distributed func distHello() { } // ok - distributed func distHelloAsync() async { } // ok - distributed func distHelloThrows() throws { } // ok - distributed func distHelloAsyncThrows() async throws { } // ok -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension D { - static func _remote_distHello(actor: D) async throws { } - static func _remote_distHelloAsync(actor: D) async throws { } - static func _remote_distHelloThrows(actor: D) async throws { } - static func _remote_distHelloAsyncThrows(actor: D) async throws { } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_not_distributed_funcs(distributed: D) async { - distributed.hello() // expected-error{{only 'distributed' functions can be called from outside the distributed actor}} - distributed.helloAsync() // expected-error{{only 'distributed' functions can be called from outside the distributed actor}} - // expected-error@-1{{expression is 'async' but is not marked with 'await'}} - // expected-note@-2{{call is 'async'}} - // {{expression is 'async' but is not marked with 'await'}}{{7-7=await }} - distributed.helloAsyncThrows() // expected-error{{only 'distributed' functions can be called from outside the distributed actor}} - // expected-error@-1{{expression is 'async' but is not marked with 'await'}} // TODO: no need to diagnose this, it is impossible to call anyway - // expected-note@-2{{call is 'async'}} - // expected-error@-3{{call can throw, but it is not marked with 'try' and the error is not handled}} // TODO: no need to diagnose this, it is impossible to call anyway -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_outside(distributed: D) async throws { - distributed.distHello() // expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-error@-1{{call can throw but is not marked with 'try'}} - // expected-note@-2{{calls to instance method 'distHello()' from outside of its actor context are implicitly asynchronous}} - // expected-note@-3{{did you mean to use 'try'?}} - // expected-note@-4{{did you mean to disable error propagation?}} - // expected-note@-5{{did you mean to handle error as optional value?}} - try distributed.distHello() // expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-note@-1{{calls to instance method 'distHello()' from outside of its actor context are implicitly asynchronous}} - await distributed.distHello() // expected-error{{call can throw but is not marked with 'try'}} - // expected-note@-1{{did you mean to use 'try'?}} - // expected-note@-2{{did you mean to disable error propagation?}} - // expected-note@-3{{did you mean to handle error as optional value?}} - try await distributed.distHello() // ok - - distributed.distHelloAsync()// expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-error@-1{{call can throw but is not marked with 'try'}} - // expected-note@-2{{calls to instance method 'distHelloAsync()' from outside of its actor context are implicitly asynchronous}} - // expected-note@-3{{did you mean to use 'try'?}} - // expected-note@-4{{did you mean to disable error propagation?}} - // expected-note@-5{{did you mean to handle error as optional value?}} - try distributed.distHelloAsync() // expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-note@-1{{calls to instance method 'distHelloAsync()' from outside of its actor context are implicitly asynchronous}} - await distributed.distHelloAsync() // expected-error{{call can throw but is not marked with 'try'}} - // expected-note@-1{{did you mean to use 'try'?}} - // expected-note@-2{{did you mean to disable error propagation?}} - // expected-note@-3{{did you mean to handle error as optional value?}} - try await distributed.distHelloAsync() // ok - - distributed.distHelloThrows() // expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-error@-1{{call can throw but is not marked with 'try'}} - // expected-note@-2{{calls to instance method 'distHelloThrows()' from outside of its actor context are implicitly asynchronous}} - // expected-note@-3{{did you mean to use 'try'?}} - // expected-note@-4{{did you mean to disable error propagation?}} - // expected-note@-5{{did you mean to handle error as optional value?}} - try distributed.distHelloThrows() // expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-note@-1{{calls to instance method 'distHelloThrows()' from outside of its actor context are implicitly asynchronous}} - await distributed.distHelloThrows() // expected-error{{call can throw but is not marked with 'try'}} - // expected-note@-1{{did you mean to use 'try'?}} - // expected-note@-2{{did you mean to disable error propagation?}} - // expected-note@-3{{did you mean to handle error as optional value?}} - try await distributed.distHelloThrows() // ok - - distributed.distHelloAsyncThrows() // expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-error@-1{{call can throw but is not marked with 'try'}} - // expected-note@-2{{calls to instance method 'distHelloAsyncThrows()' from outside of its actor context are implicitly asynchronous}} - // expected-note@-3{{did you mean to use 'try'?}} - // expected-note@-4{{did you mean to disable error propagation?}} - // expected-note@-5{{did you mean to handle error as optional value?}} - try distributed.distHelloAsyncThrows() // expected-error{{expression is 'async' but is not marked with 'await'}} - // expected-note@-1{{calls to instance method 'distHelloAsyncThrows()' from outside of its actor context are implicitly asynchronous}} - await distributed.distHelloAsyncThrows() // expected-error{{call can throw but is not marked with 'try'}} - // expected-note@-1{{did you mean to use 'try'?}} - // expected-note@-2{{did you mean to disable error propagation?}} - // expected-note@-3{{did you mean to handle error as optional value?}} - try await distributed.distHelloAsyncThrows() // ok - - // special: the actorAddress may always be referred to - _ = distributed.actorAddress // ok - _ = distributed.actorTransport // ok -} - diff --git a/test/Distributed/distributed_actor_inference.swift b/test/Distributed/distributed_actor_inference.swift deleted file mode 100644 index 24cae52c193..00000000000 --- a/test/Distributed/distributed_actor_inference.swift +++ /dev/null @@ -1,83 +0,0 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-distributed -// REQUIRES: concurrency -// REQUIRES: distributed - -import _Distributed - -actor SomeActor { } - -// ==== ------------------------------------------------------------------------ -// MARK: Declaring distributed actors -// GOOD: -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor SomeDistributedActor_0 { } - -// BAD: -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed class SomeDistributedActor_1 { } // expected-error{{'distributed' can only be applied to 'actor' definitions, and distributed actor-isolated async functions}} -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed struct SomeDistributedActor_2 { } // expected-error{{'distributed' modifier cannot be applied to this declaration}} -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed enum SomeDistributedActor_3 { } // expected-error{{'distributed' modifier cannot be applied to this declaration}} - -// ==== ------------------------------------------------------------------------ -// MARK: Declaring distributed functions -// NOTE: not distributed actor, so cannot have any distributed functions - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -struct SomeNotActorStruct_2 { - distributed func nopeAsyncThrows() async throws -> Int { 42 } // expected-error{{'distributed' function can only be declared within 'distributed actor'}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -class SomeNotActorClass_3 { - distributed func nopeAsyncThrows() async throws -> Int { 42 } // expected-error{{'distributed' function can only be declared within 'distributed actor'}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -actor SomeNotDistributedActor_4 { - distributed func notInDistActorAsyncThrowing() async throws -> Int { 42 } // expected-error{{'distributed' function can only be declared within 'distributed actor'}} -} - -protocol DP { - distributed func hello() // expected-error{{'distributed' function can only be declared within 'distributed actor'}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -protocol DPOK: DistributedActor { - distributed func hello() // ok -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -protocol DPOK2: DPOK { - distributed func again() // ok -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -enum SomeNotActorEnum_5 { - distributed func nopeAsyncThrows() async throws -> Int { 42 } // expected-error{{'distributed' function can only be declared within 'distributed actor'}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor SomeDistributedActor_6 { - distributed func yay() async throws -> Int { 42 } // ok -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension SomeDistributedActor_6 { - static func _remote_yay(actor: SomeDistributedActor_6) async throws -> Int { - fatalError() - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadValuesDistributedActor_7 { - distributed var varItNope: Int { 13 } // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed let letItNope: Int = 13 // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed lazy var lazyVarNope: Int = 13 // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed subscript(nope: Int) -> Int { nope * 2 } // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed static let staticLetNope: Int = 13 // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed static var staticVarNope: Int { 13 } // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed static func staticNope() async throws -> Int { 13 } // expected-error{{'distributed' functions cannot be 'static'}} -} - diff --git a/test/Distributed/distributed_actor_initialization.swift b/test/Distributed/distributed_actor_initialization.swift deleted file mode 100644 index 5fa77701b9d..00000000000 --- a/test/Distributed/distributed_actor_initialization.swift +++ /dev/null @@ -1,160 +0,0 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-distributed -// REQUIRES: concurrency -// REQUIRES: distributed - -import _Distributed - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor OK0 { } - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor OK1 { - var x: Int = 1 - // ok, since all fields are initialized, the constructors can be synthesized -} - -// TODO: test all the FIXITs in this file (!!!) - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor Bad1 { - init() { - // expected-error@-1 {{'distributed actor' initializer 'init()' must be 'convenience' initializer. Distributed actors have an implicitly synthesized designated 'init(transport:)' local-initializer, which other initializers must delegate to}} - // expected-error@-2 {{'distributed actor' initializer 'init()' must (directly or indirectly) delegate to 'init(transport:)}} - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor Bad11 { - convenience init() { - // expected-error@-1 {{'distributed actor' initializer 'init()' must (directly or indirectly) delegate to 'init(transport:)'}} - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor Bad12 { - init(x: String) { - // expected-error@-1 {{'distributed actor' initializer 'init(x:)' must be 'convenience' initializer. Distributed actors have an implicitly synthesized designated 'init(transport:)' local-initializer, which other initializers must delegate to}} - // expected-error@-2 {{'distributed actor' initializer 'init(x:)' must (directly or indirectly) delegate to 'init(transport:)}} - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor OK2 { - var x: Int - - convenience init(x: Int, transport: ActorTransport) { - self.init(transport: transport) - self.x = x - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor Bad2 { - var x: Int - - convenience init(x: Int, transport: ActorTransport) { - self.init(transport: transport) - self.x = x - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor Bad3 { - var x: Int - - convenience init(y: Int, transport: ActorTransport) { - // expected-error@-1 {{'distributed actor' initializer 'init(y:transport:)' must (directly or indirectly) delegate to 'init(transport:)'}} - // forgot to delegate to init(transport:) - self.x = y - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor OKMulti { - // @derived init(transport:) - - convenience init(y: Int, transport: ActorTransport) { // ok - self.init(transport: transport) - } - - convenience init(x: Int, y: Int, transport: ActorTransport) { - // ok, since we do delegate to init(transport) *eventually* - self.init(y: y, transport: transport) - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadMulti { - // @derived init(transport:) - - convenience init(y: Int, transport: ActorTransport) { - // expected-error@-1 {{'distributed actor' initializer 'init(y:transport:)' must (directly or indirectly) delegate to 'init(transport:)'}} - // self.init(transport: transport) // forgot to delegate to local init! - } - - convenience init(x: Int, y: Int, transport: ActorTransport) { - // expected-error@-1 {{'distributed actor' initializer 'init(x:y:transport:)' must (directly or indirectly) delegate to 'init(transport:)'}} - // ok, since we do delegate to init(transport) *eventually* - self.init(y: y, transport: transport) - } -} - -// It is illegal to manually invoke the resolve initializer, -// because it may result in "not a real instance" i.e. a proxy -// and a proxy does not have any storage, so it would be wrong to allow other -// initializers to keep running while we actually created a proxy with no storage. -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadResolveInitCall { - convenience init(any: Any, address: ActorAddress, transport: ActorTransport) throws { - // expected-error@-1 {{'distributed actor' initializer 'init(any:address:transport:)' cannot delegate to resolve-initializer 'init(resolve:using:)', as it may result resolving a storageless proxy instance}} - // expected-error@-2 {{'distributed actor' initializer 'init(any:address:transport:)' must (directly or indirectly) delegate to 'init(transport:)'}} - try self.init(resolve: address, using: transport) // TODO: suggest removing this call, since it is illegal - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadRedeclare1 { // expected-error {{type 'BadRedeclare1' does not conform to protocol 'DistributedActor'}} - convenience init(transport: ActorTransport) {} - // expected-error@-1 {{'distributed actor' local-initializer 'init(transport:)' cannot be implemented explicitly}} - // expected-error@-2 {{invalid redeclaration of synthesized 'init(transport:)'}} - // expected-error@-3 {{invalid redeclaration of synthesized initializer 'init(transport:)'}} - // expected-note@-4 {{candidate exactly matches}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadRedeclare11 { // expected-error {{type 'BadRedeclare11' does not conform to protocol 'DistributedActor'}} - convenience init(transport xxx: ActorTransport) {} - // expected-error@-1 {{'distributed actor' local-initializer 'init(transport:)' cannot be implemented explicitly}} - // expected-error@-2 {{invalid redeclaration of synthesized 'init(transport:)'}} - // expected-error@-3 {{invalid redeclaration of synthesized initializer 'init(transport:)'}} - // expected-note@-4 {{candidate exactly matches}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadRedeclare2 { // expected-error {{type 'BadRedeclare2' does not conform to protocol 'DistributedActor'}} - convenience init(resolve address: ActorAddress, using transport: ActorTransport) {} - // expected-error@-1 {{'distributed actor' resolve-initializer 'init(resolve:using:)' cannot be implemented explicitly}} - // expected-note@-2 {{candidate exactly matches}} - // expected-error@-3 {{invalid redeclaration of synthesized 'init(resolve:using:)'}} - // expected-error@-4 {{invalid redeclaration of synthesized initializer 'init(resolve:using:)'}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadRedeclare21 { //expected-error {{type 'BadRedeclare21' does not conform to protocol 'DistributedActor'}} - convenience init(resolve xxx: ActorAddress, using yyy: ActorTransport) {} - // expected-error@-1 {{'distributed actor' resolve-initializer 'init(resolve:using:)' cannot be implemented explicitly}} - // expected-note@-2 {{candidate exactly matches}} - // expected-error@-3 {{invalid redeclaration of synthesized 'init(resolve:using:)'}} - // expected-error@-4 {{invalid redeclaration of synthesized initializer 'init(resolve:using:)'}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor BadRedeclare22 { //expected-error {{type 'BadRedeclare22' does not conform to protocol 'DistributedActor'}} - convenience init(resolve: ActorAddress, using yyy: ActorTransport) throws {} - // expected-error@-1 {{'distributed actor' resolve-initializer 'init(resolve:using:)' cannot be implemented explicitly}} - // expected-note@-2 {{candidate exactly matches}} - // expected-error@-3 {{invalid redeclaration of synthesized 'init(resolve:using:)'}} - // expected-error@-4 {{invalid redeclaration of synthesized initializer 'init(resolve:using:)'}} -} - -// TODO: handle subclassing as well diff --git a/test/Distributed/distributed_actor_is_experimental.swift b/test/Distributed/distributed_actor_is_experimental.swift deleted file mode 100644 index 3e55b0b855f..00000000000 --- a/test/Distributed/distributed_actor_is_experimental.swift +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -// ^^^^ notice the, on purpose, missing '-enable-experimental-distributed' -// REQUIRES: concurrency - -actor SomeActor {} - -distributed actor DA {} // expected-error{{'_Distributed' module not imported, required for 'distributed actor'}} -// expected-error@-1{{class 'DA' has no initializers}} -distributed actor class DAC {} // expected-error{{'_Distributed' module not imported, required for 'distributed actor'}} -// expected-error@-1{{class 'DAC' has no initializers}} -// expected-warning@-2{{'actor class' has been renamed to 'actor'}} - -actor A { - func normal() async {} - distributed func dist() {} // expected-error{{'distributed' function can only be declared within 'distributed actor'}} - distributed func distAsync() async {} // expected-error{{'distributed' function can only be declared within 'distributed actor'}} - - distributed var neverOk: String { // expected-error{{'distributed' modifier cannot be applied to this declaration}} - "vars are not allowed to be distributed *ever* anyway" - } -} - -distributed actor DA2 { // expected-error{{'_Distributed' module not imported, required for 'distributed actor'}} - // expected-error@-1{{class 'DA2' has no initializers}} - func normal() async {} - distributed func dist() {} - distributed func distAsync() async {} - - distributed var neverOk: String { // expected-error{{'distributed' modifier cannot be applied to this declaration}} - "vars are not allowed to be distributed *ever* anyway" - } -} - -extension DA2 { - static func _remote_dist(actor: DA2) async throws {} - static func _remote_distAsync(actor: DA2) async throws {} -} diff --git a/test/Distributed/distributed_actor_isolation.swift b/test/Distributed/distributed_actor_isolation.swift deleted file mode 100644 index 058d0573d4f..00000000000 --- a/test/Distributed/distributed_actor_isolation.swift +++ /dev/null @@ -1,188 +0,0 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-distributed -// REQUIRES: concurrency -// REQUIRES: distributed - -import _Distributed - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -actor LocalActor_1 { - let name: String = "alice" - var mutable: String = "" - - distributed func nope() { - // expected-error@-1{{'distributed' function can only be declared within 'distributed actor'}} - } -} - -struct NotCodableValue { } - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed struct StructNope {} // expected-error{{distributed' modifier cannot be applied to this declaration}} -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed class ClassNope {} // expected-error{{'distributed' can only be applied to 'actor' definitions, and distributed actor-isolated async functions}} -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed enum EnumNope {} // expected-error{{distributed' modifier cannot be applied to this declaration}} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor class DistributedActor_0 { // expected-warning{{'actor class' has been renamed to 'actor'}} - distributed func okey() {} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension DistributedActor_0 { - static func _remote_okey(actor: DistributedActor_0) async throws {} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor DistributedActor_1 { - - let name: String = "alice" // expected-note{{distributed actor state is only available within the actor instance}} - var mutable: String = "alice" // expected-note{{distributed actor state is only available within the actor instance}} - var computedMutable: String { - get { - "hey" - } - set { - _ = newValue - } - } - - distributed let letProperty: String = "" // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed var varProperty: String = "" // expected-error{{'distributed' modifier cannot be applied to this declaration}} - distributed var computedProperty: String { // expected-error{{'distributed' modifier cannot be applied to this declaration}} - "" - } - - distributed static func distributedStatic() {} // expected-error{{'distributed' functions cannot be 'static'}} - - func hello() {} // expected-note{{only 'distributed' functions can be called from outside the distributed actor}} - func helloAsync() async {} // expected-note{{only 'distributed' functions can be called from outside the distributed actor}} - func helloAsyncThrows() async throws {} // expected-note{{only 'distributed' functions can be called from outside the distributed actor}} - - distributed func distHello() { } // ok - distributed func distHelloAsync() async { } // ok - distributed func distHelloThrows() throws { } // ok - distributed func distHelloAsyncThrows() async throws { } // ok - - distributed func distInt() async throws -> Int { 42 } // ok - distributed func distInt(int: Int) async throws -> Int { int } // ok - - distributed func dist(notCodable: NotCodableValue) async throws { - // expected-error@-1 {{distributed function parameter 'notCodable' of type 'NotCodableValue' does not conform to 'Codable'}} - } - distributed func distBadReturn(int: Int) async throws -> NotCodableValue { - // expected-error@-1 {{distributed function result type 'NotCodableValue' does not conform to 'Codable'}} - fatalError() - } - - distributed func distReturnGeneric(int: Int) async throws -> T { // ok - fatalError() - } - distributed func distReturnGenericWhere(int: Int) async throws -> T where T: Codable { // ok - fatalError() - } - distributed func distBadReturnGeneric(int: Int) async throws -> T { - // expected-error@-1 {{distributed function result type 'T' does not conform to 'Codable'}} - fatalError() - } - - distributed func distGenericParam(value: T) async throws { // ok - fatalError() - } - distributed func distGenericParamWhere(value: T) async throws -> T where T: Codable { // ok - fatalError() - } - distributed func distBadGenericParam(int: T) async throws { - // expected-error@-1 {{distributed function parameter 'int' of type 'T' does not conform to 'Codable'}} - fatalError() - } - - func test_inside() async throws { - _ = self.name - _ = self.computedMutable - - _ = try await self.distInt() - _ = try await self.distInt(int: 42) - - self.hello() - _ = await self.helloAsync() - _ = try await self.helloAsyncThrows() - - self.distHello() - await self.distHelloAsync() - try self.distHelloThrows() - try await self.distHelloAsyncThrows() - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension DistributedActor_1 { - static func _remote_distHello(actor: DistributedActor_1) async throws { } - static func _remote_distHelloAsync(actor: DistributedActor_1) async throws { } - static func _remote_distHelloThrows(actor: DistributedActor_1) async throws { } - static func _remote_distHelloAsyncThrows(actor: DistributedActor_1) async throws { } - - static func _remote_distInt(actor: DistributedActor_1) async throws -> Int { 42 } - static func _remote_distInt(int: Int, actor: DistributedActor_1) async throws -> Int { int } - - static func _remote_distReturnGeneric(int: Int, actor: DistributedActor_1) async throws -> T { - fatalError() - } - static func _remote_distReturnGenericWhere(int: Int, actor: DistributedActor_1) async throws -> T where T: Codable { - fatalError() - } - - static func _remote_distGenericParam(value: T, actor: DistributedActor_1) async throws { - fatalError() - } - static func _remote_distGenericParamWhere(value: T, actor: DistributedActor_1) async throws -> T where T: Codable { - fatalError() - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_outside( - local: LocalActor_1, - distributed: DistributedActor_1 -) async throws { - // ==== properties - _ = distributed.actorAddress // ok - distributed.actorAddress = ActorAddress(parse: "mock://1.1.1.1:8080/#123121") // expected-error{{cannot assign to property: 'actorAddress' is immutable}} - - _ = local.name // ok, special case that let constants are okey - let _: String = local.mutable // ok, special case that let constants are okey - _ = distributed.name // expected-error{{distributed actor-isolated property 'name' can only be referenced inside the distributed actor}} - _ = distributed.mutable // expected-error{{distributed actor-isolated property 'mutable' can only be referenced inside the distributed actor}} - - // ==== special properties (@_distributedActorIndependent) - // the distributed actor's special fields may always be referred to - _ = distributed.actorAddress - _ = distributed.actorTransport - - // ==== non-distributed functions - _ = await distributed.hello() // expected-error{{only 'distributed' functions can be called from outside the distributed actor}} - _ = await distributed.helloAsync() // expected-error{{only 'distributed' functions can be called from outside the distributed actor}} - _ = try await distributed.helloAsyncThrows() // expected-error{{only 'distributed' functions can be called from outside the distributed actor}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor DistributedActor_2 { - // TODO: should report the error on the remote function instead? - distributed func okey() {} // expected-error{{remote function '_remote_okey()' must be static.}} -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension DistributedActor_2 { - func _remote_okey() {} -} - -// ==== Codable parameters and return types ------------------------------------ - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func test_params( - distributed: DistributedActor_1 -) async throws { - _ = try await distributed.distInt() // ok - _ = try await distributed.distInt(int: 42) // ok - _ = try await distributed.dist(notCodable: .init()) -} diff --git a/test/Distributed/distributed_missing_import.swift b/test/Distributed/distributed_missing_import.swift deleted file mode 100644 index 9f9af36197f..00000000000 --- a/test/Distributed/distributed_missing_import.swift +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-distributed -// REQUIRES: concurrency -// REQUIRES: distributed - -actor SomeActor { } - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor MissingImportDistributedActor_0 { } // expected-error{{'_Distributed' module not imported, required for 'distributed actor'}} -// expected-error@-1{{class 'MissingImportDistributedActor_0' has no initializers}} - -let t: ActorTransport // expected-error{{cannot find type 'ActorTransport' in scope}} -let a: ActorAddress // expected-error{{cannot find type 'ActorAddress' in scope}} - diff --git a/test/IRGen/distributed_actor_class.swift b/test/IRGen/distributed_actor_class.swift deleted file mode 100644 index cf5553c59c9..00000000000 --- a/test/IRGen/distributed_actor_class.swift +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -enable-experimental-distributed | %IRGenFileCheck %s -// REQUIRES: concurrency -// REQUIRES: distributed - -import _Distributed - -// Type descriptor. -// CHECK-LABEL: @"$s23distributed_actor_class7MyActorC0B7Address12_Distributed0eF0VvpWvd" - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -public distributed actor MyActor { - // nothing -} diff --git a/test/ScanDependencies/can_import_with_map.swift b/test/ScanDependencies/can_import_with_map.swift index 3df7d64b2a6..ef99ad15e19 100644 --- a/test/ScanDependencies/can_import_with_map.swift +++ b/test/ScanDependencies/can_import_with_map.swift @@ -25,11 +25,6 @@ // RUN: echo "\"moduleName\": \"_Concurrency\"," >> %/t/inputs/map.json // RUN: echo "\"modulePath\": \"%/concurrency_module\"," >> %/t/inputs/map.json // RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json -// RUN: echo "}," >> %/t/inputs/map.json -// RUN: echo "{" >> %/t/inputs/map.json -// RUN: echo "\"moduleName\": \"_Distributed\"," >> %/t/inputs/map.json -// RUN: echo "\"modulePath\": \"%/distributed_module\"," >> %/t/inputs/map.json -// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json // RUN: echo "}]" >> %/t/inputs/map.json // RUN: %target-swift-frontend -typecheck %s -explicit-swift-module-map-file %t/inputs/map.json -disable-implicit-swift-modules diff --git a/test/ScanDependencies/explicit-framework-irgen.swift b/test/ScanDependencies/explicit-framework-irgen.swift index a1f9bca25c3..1720251f204 100644 --- a/test/ScanDependencies/explicit-framework-irgen.swift +++ b/test/ScanDependencies/explicit-framework-irgen.swift @@ -26,11 +26,6 @@ // RUN: echo "\"moduleName\": \"_Concurrency\"," >> %/t/inputs/map.json // RUN: echo "\"modulePath\": \"%/concurrency_module\"," >> %/t/inputs/map.json // RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json -// RUN: echo "}," >> %/t/inputs/map.json -// RUN: echo "{" >> %/t/inputs/map.json -// RUN: echo "\"moduleName\": \"_Distributed\"," >> %/t/inputs/map.json -// RUN: echo "\"modulePath\": \"%/distributed_module\"," >> %/t/inputs/map.json -// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json // RUN: echo "}]" >> %/t/inputs/map.json // RUN: %target-swift-frontend -emit-object -emit-module -disable-implicit-swift-modules -explicit-swift-module-map-file %t/inputs/map.json -o %t/explicit-framework-irgen.o %s diff --git a/test/ScanDependencies/explicit-module-map-forwarding-module.swift b/test/ScanDependencies/explicit-module-map-forwarding-module.swift index 26bafeabfd3..9b9a5d40e65 100644 --- a/test/ScanDependencies/explicit-module-map-forwarding-module.swift +++ b/test/ScanDependencies/explicit-module-map-forwarding-module.swift @@ -35,11 +35,6 @@ // RUN: echo "\"moduleName\": \"_Concurrency\"," >> %/t/inputs/map.json // RUN: echo "\"modulePath\": \"%/concurrency_module\"," >> %/t/inputs/map.json // RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json -// RUN: echo "}," >> %/t/inputs/map.json -// RUN: echo "{" >> %/t/inputs/map.json -// RUN: echo "\"moduleName\": \"_Distributed\"," >> %/t/inputs/map.json -// RUN: echo "\"modulePath\": \"%/distributed_module\"," >> %/t/inputs/map.json -// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json // RUN: echo "}]" >> %/t/inputs/map.json // RUN: %target-swift-ide-test -print-module-comments -module-to-print=Foo -enable-swiftsourceinfo -source-filename %s -explicit-swift-module-map-file %t/inputs/map.json | %FileCheck %s diff --git a/test/Serialization/Inputs/def_distributed.swift b/test/Serialization/Inputs/def_distributed.swift deleted file mode 100644 index a170021d0f9..00000000000 --- a/test/Serialization/Inputs/def_distributed.swift +++ /dev/null @@ -1,15 +0,0 @@ -import _Distributed - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor DA { - public distributed func doSomethingDistributed() async -> Int { - return 0 - } -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -extension DA { - public static func _remote_doSomethingDistributed() async throws -> Int { - fatalError() - } -} diff --git a/test/Serialization/distributed.swift b/test/Serialization/distributed.swift deleted file mode 100644 index f52bfe07371..00000000000 --- a/test/Serialization/distributed.swift +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %empty-directory(%t) -// RUN: %empty-directory(%t-scratch) -// RUN: %target-swift-frontend -emit-module -o %t-scratch/def_async~partial.swiftmodule -primary-file %S/Inputs/def_distributed.swift -module-name def_async -enable-experimental-distributed -// RUN: %target-swift-frontend -merge-modules -emit-module -parse-as-library -enable-testing %t-scratch/def_distributed~partial.swiftmodule -module-name def_async -o %t/def_async.swiftmodule -enable-experimental-distributed -// RUN: %target-swift-frontend -typecheck -I%t -verify %s -verify-ignore-unknown -enable-experimental-distributed - -// REQUIRES: concurrency -// REQUIRES: distributed - -// TODO: fix this test, not sure what the issue is hm -// XFAIL: * - -import def_distributed - -func testDoSomethingDistributed() { - // TODO: do the test -} diff --git a/test/Unit/lit.site.cfg.in b/test/Unit/lit.site.cfg.in index ca000f60661..1744b297c59 100644 --- a/test/Unit/lit.site.cfg.in +++ b/test/Unit/lit.site.cfg.in @@ -10,7 +10,6 @@ config.target_triple = "@TARGET_TRIPLE@" config.swiftlib_dir = "@LIT_SWIFTLIB_DIR@" config.swift_test_results_dir = \ lit_config.params.get("swift_test_results_dir", "@SWIFT_TEST_RESULTS_DIR@") -config.lit_site_config_folder = os.path.dirname(os.path.realpath(__file__)) config.coverage_mode = "@SWIFT_ANALYZE_CODE_COVERAGE@" diff --git a/test/decl/protocol/special/DistributedActor.swift b/test/decl/protocol/special/DistributedActor.swift deleted file mode 100644 index 1d7d8edcbd8..00000000000 --- a/test/decl/protocol/special/DistributedActor.swift +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-distributed -// REQUIRES: concurrency -// REQUIRES: distributed - -import _Distributed - -// Synthesis of distributed actors. - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor D1 { - var x: Int = 17 -} - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -distributed actor D2 { - let actorTransport: String // expected-error{{invalid redeclaration of synthesized implementation for protocol requirement 'actorTransport'}} - let actorAddress: String // expected-error{{invalid redeclaration of synthesized implementation for protocol requirement 'actorAddress'}} -} - -// ==== Tests ------------------------------------------------------------------ - -// Make sure the conformances actually happen. -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func acceptActor(_: Act.Type) { } - -@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) -func testConformance() { - acceptActor(D1.self) -} diff --git a/test/lit.cfg b/test/lit.cfg index 906371cbde1..497d4512ac5 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -1616,13 +1616,6 @@ config.substitutions.append(('%concurrency_module', concurrency_module)) config.substitutions.append(('%/concurrency_module', '/'.join(os.path.normpath(concurrency_module).split(os.sep)))) -# Add 'distributed_module' as the path to the _Distributed .swiftmodule file -distributed_module = os.path.join(stdlib_dir, "_Distributed.swiftmodule", - target_specific_module_triple + ".swiftmodule") -config.substitutions.append(('%distributed_module', distributed_module)) -config.substitutions.append(('%/distributed_module', - '/'.join(os.path.normpath(distributed_module).split(os.sep)))) - # Different OS's require different prefixes for the environment variables to be # propagated to the calling contexts. # In order to make tests OS-agnostic, names of environment variables should be diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 6f39e4bd258..51723d0c110 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -128,8 +128,6 @@ if "@SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING@" == "TRUE": config.available_features.add('differentiable_programming') if "@SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY@" == "TRUE": config.available_features.add('concurrency') -if "@SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED@" == "TRUE": - config.available_features.add('distributed') # Let the main config do the real work. if config.test_exec_root is None: diff --git a/tools/sil-opt/SILOpt.cpp b/tools/sil-opt/SILOpt.cpp index 46c1545f6c8..7681d2f5d10 100644 --- a/tools/sil-opt/SILOpt.cpp +++ b/tools/sil-opt/SILOpt.cpp @@ -103,10 +103,6 @@ static llvm::cl::opt EnableExperimentalConcurrency("enable-experimental-concurrency", llvm::cl::desc("Enable experimental concurrency model.")); -static llvm::cl::opt -EnableExperimentalDistributed("enable-experimental-distributed", - llvm::cl::desc("Enable experimental distributed actors.")); - static llvm::cl::opt VerifyExclusivity("enable-verify-exclusivity", llvm::cl::desc("Verify the access markers used to enforce exclusivity.")); diff --git a/tools/swift-ide-test/swift-ide-test.cpp b/tools/swift-ide-test/swift-ide-test.cpp index 850548d229e..48db939e05e 100644 --- a/tools/swift-ide-test/swift-ide-test.cpp +++ b/tools/swift-ide-test/swift-ide-test.cpp @@ -757,11 +757,6 @@ DisableImplicitConcurrencyImport("disable-implicit-concurrency-module-import", llvm::cl::desc("Disable implicit import of _Concurrency module"), llvm::cl::init(false)); -static llvm::cl::opt -EnableExperimentalDistributed("enable-experimental-distributed", - llvm::cl::desc("Enable experimental distributed actors and functions"), - llvm::cl::init(false)); - static llvm::cl::list AccessNotesPath("access-notes-path", llvm::cl::desc("Path to access notes file"), llvm::cl::cat(Category)); @@ -3852,13 +3847,6 @@ int main(int argc, char *argv[]) { InitInvok.getLangOptions().DisableImplicitConcurrencyModuleImport = true; } - if (options::EnableExperimentalDistributed) { - // distributed implies concurrency features: - InitInvok.getLangOptions().EnableExperimentalConcurrency = true; - // enable 'distributed' parsing and features - InitInvok.getLangOptions().EnableExperimentalDistributed = true; - } - if (!options::Triple.empty()) InitInvok.setTargetTriple(options::Triple); if (!options::SwiftVersion.empty()) { diff --git a/unittests/runtime/CMakeLists.txt b/unittests/runtime/CMakeLists.txt index 90d837105ed..d7ae719204e 100644 --- a/unittests/runtime/CMakeLists.txt +++ b/unittests/runtime/CMakeLists.txt @@ -84,15 +84,6 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND endif() endif() - if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED) -# list(APPEND PLATFORM_SOURCES -# DistributedActor.cpp -# ) - list(APPEND PLATFORM_TARGET_LINK_LIBRARIES - swift_Distributed${SWIFT_PRIMARY_VARIANT_SUFFIX} - ) - endif() - # Don't complain about these files not being in the sources list. set(LLVM_OPTIONAL_SOURCES weak.mm diff --git a/utils/build-presets.ini b/utils/build-presets.ini index f6bf5700ca4..eb1c1a01f77 100644 --- a/utils/build-presets.ini +++ b/utils/build-presets.ini @@ -2405,7 +2405,6 @@ verbose-build [preset: mixin_stdlib_minimal] enable-experimental-differentiable-programming=0 enable-experimental-concurrency=0 -enable-experimental-distributed=0 build-swift-dynamic-sdk-overlay=0 build-swift-dynamic-stdlib=0 build-swift-static-stdlib=1 diff --git a/utils/build-windows.bat b/utils/build-windows.bat index 39ae18998ee..1e446f042a9 100644 --- a/utils/build-windows.bat +++ b/utils/build-windows.bat @@ -265,7 +265,6 @@ cmake^ -DSWIFT_BUILD_SOURCEKIT:BOOL=YES^ -DSWIFT_ENABLE_SOURCEKIT_TESTS:BOOL=YES^ -DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES^ - -DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES^ -DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES^ -DSWIFT_INSTALL_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;stdlib;sdk-overlay;editor-integration;tools;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers"^ -DSWIFT_PARALLEL_LINK_JOBS=8^ diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py index 97482e7c82e..5def4a11076 100644 --- a/utils/build_swift/build_swift/driver_arguments.py +++ b/utils/build_swift/build_swift/driver_arguments.py @@ -1171,10 +1171,6 @@ def create_argument_parser(): default=True, help='Enable experimental Swift concurrency model.') - option('--enable-experimental-distributed', toggle_true, - default=True, - help='Enable experimental Swift distributed actors.') - # ------------------------------------------------------------------------- in_group('Unsupported options') diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py index 2ab95c997c3..f728f518087 100644 --- a/utils/build_swift/tests/expected_options.py +++ b/utils/build_swift/tests/expected_options.py @@ -146,7 +146,6 @@ EXPECTED_DEFAULTS = { 'enable_asan': False, 'enable_experimental_differentiable_programming': True, 'enable_experimental_concurrency': True, - 'enable_experimental_distributed': True, 'enable_lsan': False, 'enable_sanitize_coverage': False, 'disable_guaranteed_normal_arguments': False, @@ -522,7 +521,6 @@ EXPECTED_OPTIONS = [ EnableOption('--enable-asan'), EnableOption('--enable-experimental-differentiable-programming'), EnableOption('--enable-experimental-concurrency'), - EnableOption('--enable-experimental-distributed'), EnableOption('--enable-lsan'), EnableOption('--enable-sanitize-coverage'), EnableOption('--enable-tsan'), diff --git a/utils/swift-api-dump.py b/utils/swift-api-dump.py index d3114e3583f..f0071b85bf9 100755 --- a/utils/swift-api-dump.py +++ b/utils/swift-api-dump.py @@ -330,8 +330,6 @@ def main(): extra_args = ['-skip-imports'] if args.enable_experimental_concurrency: extra_args = extra_args + ['-enable-experimental-concurrency'] - if args.enable_experimental_distributed: - extra_args = extra_args + ['-enable-experimental-distributed'] if args.swift_version: extra_args = extra_args + ['-swift-version', '%s' % args.swift_version] diff --git a/utils/swift_build_support/swift_build_support/products/swift.py b/utils/swift_build_support/swift_build_support/products/swift.py index 265fff0be9e..661df9103ac 100644 --- a/utils/swift_build_support/swift_build_support/products/swift.py +++ b/utils/swift_build_support/swift_build_support/products/swift.py @@ -52,9 +52,6 @@ class Swift(product.Product): # Add experimental concurrency flag. self.cmake_options.extend(self._enable_experimental_concurrency) - # Add experimental distributed flag. - self.cmake_options.extend(self._enable_experimental_distributed) - @classmethod def is_build_script_impl_product(cls): """is_build_script_impl_product -> bool @@ -149,11 +146,6 @@ updated without updating swift.py?") return [('SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL', self.args.enable_experimental_concurrency)] - @property - def _enable_experimental_distributed(self): - return [('SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL', - self.args.enable_experimental_distributed)] - @classmethod def get_dependencies(cls): return [cmark.CMark, diff --git a/utils/swift_build_support/tests/products/test_swift.py b/utils/swift_build_support/tests/products/test_swift.py index 091452a4bd9..318ba79d826 100644 --- a/utils/swift_build_support/tests/products/test_swift.py +++ b/utils/swift_build_support/tests/products/test_swift.py @@ -59,8 +59,7 @@ class SwiftTestCase(unittest.TestCase): force_optimized_typechecker=False, enable_stdlibcore_exclusivity_checking=False, enable_experimental_differentiable_programming=False, - enable_experimental_concurrency=False, - enable_experimental_distributed=False) + enable_experimental_concurrency=False) # Setup shell shell.dry_run = True @@ -93,7 +92,6 @@ class SwiftTestCase(unittest.TestCase): '-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=FALSE', - '-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE' ] self.assertEqual(set(swift.cmake_options), set(expected)) @@ -110,8 +108,7 @@ class SwiftTestCase(unittest.TestCase): '-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER:BOOL=FALSE', '-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=FALSE', - '-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=FALSE', - '-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE' + '-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=FALSE' ] self.assertEqual(set(swift.cmake_options), set(flags_set)) @@ -337,16 +334,3 @@ class SwiftTestCase(unittest.TestCase): 'TRUE'], [x for x in swift.cmake_options if 'DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY' in x]) - - def test_experimental_distributed_flags(self): - self.args.enable_experimental_distributed = True - swift = Swift( - args=self.args, - toolchain=self.toolchain, - source_dir='/path/to/src', - build_dir='/path/to/build') - self.assertEqual( - ['-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=' - 'TRUE'], - [x for x in swift.cmake_options - if 'DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED' in x])