mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This is possible because actors do not support inheritance. There is one specific exception to that rule, which is that an actor can inherit from `NSObject` just to support ObjC interop. This means an actor is effectively a final class. resolves rdar://87568153
72 lines
1.7 KiB
Swift
72 lines
1.7 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/Inputs/FakeDistributedActorSystems.swift
|
|
// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking -I %t 2>&1 %s
|
|
// REQUIRES: concurrency
|
|
// REQUIRES: distributed
|
|
|
|
import Distributed
|
|
import FakeDistributedActorSystems
|
|
|
|
@available(SwiftStdlib 5.5, *)
|
|
typealias DefaultDistributedActorSystem = FakeActorSystem
|
|
|
|
// ==== ----------------------------------------------------------------------------------------------------------------
|
|
|
|
distributed actor OK0 { }
|
|
|
|
distributed actor OK1 {
|
|
var x: Int = 1
|
|
// ok, since all fields are initialized, the constructor can be synthesized
|
|
}
|
|
|
|
distributed actor OK2 {
|
|
var x: Int
|
|
|
|
init(x: Int, system: FakeActorSystem) { // ok
|
|
self.x = x
|
|
}
|
|
}
|
|
|
|
// NOTE: keep in mind this is only through typechecking, so no explicit
|
|
// actorSystem is being assigned here.
|
|
distributed actor OK3 {
|
|
init() {}
|
|
}
|
|
|
|
distributed actor OK4 {
|
|
init(x: String) {
|
|
}
|
|
}
|
|
|
|
distributed actor OK5 {
|
|
var x: Int = 1
|
|
|
|
init(system: FakeActorSystem, too many: FakeActorSystem) {
|
|
}
|
|
}
|
|
|
|
distributed actor OK6 {
|
|
var x: Int
|
|
|
|
init(y: Int, system: FakeActorSystem) {
|
|
self.x = y
|
|
}
|
|
}
|
|
|
|
distributed actor OKMulti {
|
|
|
|
convenience init(y: Int, system: FakeActorSystem) { // expected-warning{{initializers in actors are not marked with 'convenience'; this is an error in Swift 6}}{{3-15=}}
|
|
self.init(actorSystem: system)
|
|
}
|
|
|
|
}
|
|
|
|
distributed actor OKMultiDefaultValues {
|
|
|
|
init(y: Int, system: FakeActorSystem, x: Int = 1234) { // ok
|
|
self.init(actorSystem: system)
|
|
}
|
|
|
|
}
|
|
|