Skip to content

Commit 083962d

Browse files
committed
[Tests] NFC: Add a test-case for main-actor isolated struct and nonisolated protocol
1 parent 7e42a19 commit 083962d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/Concurrency/nonisolated_rules.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,20 @@ struct TestEnum {
196196
}
197197
}
198198

199+
nonisolated protocol NonisolatedWithMembers {
200+
func test()
201+
}
202+
203+
@MainActor
204+
struct TestIsolated : NonisolatedWithMembers {
205+
var x: NonSendable // expected-note {{property declared here}}
206+
207+
// requirement behaves as if it's explicitly `nonisolated` which gets inferred onto the witness
208+
func test() {
209+
_ = x // expected-error {{main actor-isolated property 'x' can not be referenced from a nonisolated context}}
210+
}
211+
}
212+
199213
// MARK: - Classes
200214

201215
nonisolated class K: GloballyIsolated {

0 commit comments

Comments
 (0)