File tree Expand file tree Collapse file tree 2 files changed +47
-8
lines changed Expand file tree Collapse file tree 2 files changed +47
-8
lines changed Original file line number Diff line number Diff line change 1+ import Foundation
12
23// This input is useful to ensure the delegation status of
34// an actor's initializer does not affect ABI stability
4- public actor BigFoot {
55
6- public let name : String
6+ public protocol NamedEntity : Actor {
7+ nonisolated var name : String ? { get }
8+ }
9+
10+ public actor BigFoot : NamedEntity {
11+
12+ public nonisolated let name : String ?
13+
14+ private init ( withName name: String ) {
15+ self . name = name
16+ }
17+
18+ public init ( ) {
19+ #if DELEGATES
20+ self . init ( withName: " Sasquatch " )
21+ #else
22+ self . name = nil
23+ #endif
24+ }
25+ }
26+
27+
28+ @objc public actor BigFootObjC : NSObject , NamedEntity {
29+
30+ public nonisolated let name : String ?
731
832 private init ( withName name: String ) {
933 self . name = name
1034 }
1135
12- public init ? ( ) {
36+ @ objc public override init ( ) {
1337 #if DELEGATES
1438 self . init ( withName: " Sasquatch " )
1539 #else
16- return nil
40+ self . name = nil
1741 #endif
1842 }
1943}
Original file line number Diff line number Diff line change 4747
4848// REQUIRES: executable_test
4949// REQUIRES: concurrency
50+ // REQUIRES: objc_interop
5051
5152// rdar://76038845
5253// REQUIRES: concurrency_runtime
5354// UNSUPPORTED: back_deployment_runtime
5455
5556import MysteryInit
5657
57- @main
58- struct Main {
59- static func main( ) {
60- switch BigFoot ( ) {
58+ // NOTE: the number of myth/real checks in this function (in either mode) should
59+ // match the number of times `test` is called. The -NOT check is there to catch
60+ // any mistakes in updating the test.
61+ func test( _ bigFoot: any NamedEntity ) {
62+ switch bigFoot. name {
6163 case . none:
6264 print ( " bigfoot is myth " )
6365 // CHECK-NO-DELEGATES: bigfoot is myth
66+ // CHECK-NO-DELEGATES: bigfoot is myth
67+
68+ // CHECK-NO-DELEGATES-NOT: bigfoot
6469 default :
6570 print ( " bigfoot is real " )
6671 // CHECK-DELEGATES: bigfoot is real
72+ // CHECK-DELEGATES: bigfoot is real
73+
74+ // CHECK-DELEGATES-NOT: bigfoot
6775 }
76+ }
77+
78+ @main
79+ struct Main {
80+ static func main( ) {
81+ test ( BigFoot ( ) )
82+ test ( BigFootObjC ( ) )
6883 }
6984}
You can’t perform that action at this time.
0 commit comments