You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SE-0466] Treat explicit "nonisolated" like implicit "nonisolated" on protocols
Make explicit "nonisolated" also not special on protocols, so a
nonisolated protocol does not suppress default isolation.
SendableMetatype is the proper way to suppress default isolation for a
protocol.
Unfortunately, these rules made it appear like issue #82168
was fixed, when in fact it was not. Keep the test case, but as a
failing test, and we'll investigate separately.
Copy file name to clipboardExpand all lines: test/Concurrency/isolated_conformance_default_actor.swift
+13-4Lines changed: 13 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
// REQUIRES: concurrency
4
4
5
+
@MainActorfunc onMain(){}
6
+
5
7
nonisolated
6
8
protocolP{
7
9
func f()
@@ -12,8 +14,14 @@ protocol Q {
12
14
func g()
13
15
}
14
16
17
+
// expected-note@+4{{turn data races into runtime errors with '@preconcurrency'}}
18
+
// expected-note@+3{{isolate this conformance to the main actor with '@MainActor'}}
19
+
// expected-note@+2{{mark all declarations used in the conformance 'nonisolated'}}
20
+
// expected-error@+1{{conformance of 'CImplicitMainActorNonisolatedConformance' to protocol 'P' crosses into main actor-isolated code and can cause data races}}
15
21
classCImplicitMainActorNonisolatedConformance:nonisolated P {
// Error, these are main-actor-isolated conformances
92
+
let _:anyP=CExplicitMainActor() // expected-error{{main actor-isolated conformance of 'CExplicitMainActor' to 'P' cannot be used in nonisolated context}}
93
+
let _:anyP=CImplicitMainActor() // expected-error{{main actor-isolated conformance of 'CImplicitMainActor' to 'P' cannot be used in nonisolated context}}
94
+
95
+
87
96
let _:anyEquatable.Type=EquatableStruct.self // expected-error{{main actor-isolated conformance of 'EquatableStruct' to 'Equatable' cannot be used in nonisolated context}}
88
97
let _:anyHashable.Type=HashableStruct.self // expected-error{{main actor-isolated conformance of 'HashableStruct' to 'Hashable' cannot be used in nonisolated context}}
89
98
let _:anyRawRepresentable.Type=RawRepresentableEnum.self
0 commit comments