File tree Expand file tree Collapse file tree 2 files changed +46
-8
lines changed Expand file tree Collapse file tree 2 files changed +46
-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 54
54
55
55
import MysteryInit
56
56
57
- @main
58
- struct Main {
59
- static func main( ) {
60
- switch BigFoot ( ) {
57
+ // NOTE: the number of myth/real checks in this function (in either mode) should
58
+ // match the number of times `test` is called. The -NOT check is there to catch
59
+ // any mistakes in updating the test.
60
+ func test( _ bigFoot: any NamedEntity ) {
61
+ switch bigFoot. name {
61
62
case . none:
62
63
print ( " bigfoot is myth " )
63
64
// CHECK-NO-DELEGATES: bigfoot is myth
65
+ // CHECK-NO-DELEGATES: bigfoot is myth
66
+
67
+ // CHECK-NO-DELEGATES-NOT: bigfoot
64
68
default :
65
69
print ( " bigfoot is real " )
66
70
// CHECK-DELEGATES: bigfoot is real
71
+ // CHECK-DELEGATES: bigfoot is real
72
+
73
+ // CHECK-DELEGATES-NOT: bigfoot
67
74
}
75
+ }
76
+
77
+ @main
78
+ struct Main {
79
+ static func main( ) {
80
+ test ( BigFoot ( ) )
81
+ test ( BigFootObjC ( ) )
68
82
}
69
83
}
You can’t perform that action at this time.
0 commit comments