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
let _:anyP=CExplicitMainActor() // expected-error{{main actor-isolated conformance of 'CExplicitMainActor' to 'P' cannot be used in nonisolated context}}
50
-
let _:anyP=CImplicitMainActor() // expected-error{{main actor-isolated conformance of 'CImplicitMainActor' to 'P' cannot be used in nonisolated context}}
67
+
let _:anyP=CExplicitMainActor() // okay
68
+
let _:anyP=CImplicitMainActor() // okay
51
69
52
70
let _:anyP=CNonIsolated()
53
71
let _:anyP=CImplicitMainActorNonisolatedConformance()
54
72
55
73
// Okay, these are nonisolated conformances.
56
74
let _:anyQ=CExplicitMainActor()
57
75
let _:anyQ=CImplicitMainActor()
76
+
77
+
// Error, these are main-actor-isolated conformances
78
+
let _:anyEquatable.Type=EquatableStruct.self // expected-error{{main actor-isolated conformance of 'EquatableStruct' to 'Equatable' cannot be used in nonisolated context}}
79
+
let _:anyHashable.Type=HashableStruct.self // expected-error{{main actor-isolated conformance of 'HashableStruct' to 'Hashable' cannot be used in nonisolated context}}
80
+
let _:anyRawRepresentable.Type=RawRepresentableEnum.self
81
+
let _:anyEncodable.Type=CodableClass.self // expected-error{{main actor-isolated conformance of 'CodableClass' to 'Encodable' cannot be used in nonisolated context}}
Copy file name to clipboardExpand all lines: test/Concurrency/isolated_conformance_inference.swift
+24-1Lines changed: 24 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,11 @@ extension CExplicit: Q {
32
32
func g(){}
33
33
}
34
34
35
+
@SomeGlobalActor
36
+
classCViaNonisolatedWitness:P{
37
+
nonisolatedfunc f(){} // okay! conformance above is nonisolated via this witness
38
+
}
39
+
35
40
// expected-error@+3{{conformance of 'CNonIsolated' to protocol 'P' crosses into global actor 'SomeGlobalActor'-isolated code and can cause data races}}
36
41
// expected-note@+2{{turn data races into runtime errors with '@preconcurrency'}}
37
42
// expected-note@+1{{isolate this conformance to the global actor 'SomeGlobalActor' with '@SomeGlobalActor'}}{{33-33=@SomeGlobalActor }}
@@ -42,11 +47,29 @@ nonisolated class CNonIsolated: P {
let _:anyP=CExplicit() // expected-error{{global actor 'SomeGlobalActor'-isolated conformance of 'CExplicit' to 'P' cannot be used in nonisolated context}}
0 commit comments