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
1
2
2
3
// This input is useful to ensure the delegation status of
3
4
// an actor's initializer does not affect ABI stability
4
- public actor BigFoot {
5
5
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 ?
7
31
8
32
private init ( withName name: String ) {
9
33
self . name = name
10
34
}
11
35
12
- public init ? ( ) {
36
+ @ objc public override init ( ) {
13
37
#if DELEGATES
14
38
self . init ( withName: " Sasquatch " )
15
39
#else
16
- return nil
40
+ self . name = nil
17
41
#endif
18
42
}
19
43
}
Original file line number Diff line number Diff line change 47
47
48
48
// REQUIRES: executable_test
49
49
// REQUIRES: concurrency
50
+ // REQUIRES: objc_interop
50
51
51
52
// rdar://76038845
52
53
// REQUIRES: concurrency_runtime
53
54
// UNSUPPORTED: back_deployment_runtime
54
55
55
56
import MysteryInit
56
57
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 {
61
63
case . none:
62
64
print ( " bigfoot is myth " )
63
65
// CHECK-NO-DELEGATES: bigfoot is myth
66
+ // CHECK-NO-DELEGATES: bigfoot is myth
67
+
68
+ // CHECK-NO-DELEGATES-NOT: bigfoot
64
69
default :
65
70
print ( " bigfoot is real " )
66
71
// CHECK-DELEGATES: bigfoot is real
72
+ // CHECK-DELEGATES: bigfoot is real
73
+
74
+ // CHECK-DELEGATES-NOT: bigfoot
67
75
}
76
+ }
77
+
78
+ @main
79
+ struct Main {
80
+ static func main( ) {
81
+ test ( BigFoot ( ) )
82
+ test ( BigFootObjC ( ) )
68
83
}
69
84
}
You can’t perform that action at this time.
0 commit comments