Skip to content

Commit 9109bdc

Browse files
committed
add objc coverage to actor_init_abi test
1 parent e1d1aee commit 9109bdc

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
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
}

test/Concurrency/Runtime/actor_init_abi.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,30 @@
5454

5555
import MysteryInit
5656

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 {
6162
case .none:
6263
print("bigfoot is myth")
6364
// CHECK-NO-DELEGATES: bigfoot is myth
65+
// CHECK-NO-DELEGATES: bigfoot is myth
66+
67+
// CHECK-NO-DELEGATES-NOT: bigfoot
6468
default:
6569
print("bigfoot is real")
6670
// CHECK-DELEGATES: bigfoot is real
71+
// CHECK-DELEGATES: bigfoot is real
72+
73+
// CHECK-DELEGATES-NOT: bigfoot
6774
}
75+
}
76+
77+
@main
78+
struct Main {
79+
static func main() {
80+
test(BigFoot())
81+
test(BigFootObjC())
6882
}
6983
}

0 commit comments

Comments
 (0)