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
Respect @preconcurrency on nominal types uniformly
When determining whether a non-sendable type is a nominal type that is
affected by `@preconcurrency`, be sure to look at the specific type
even when it's part of larger type, e.g., the `NS` in `NS?`. This
makes `@preconcurrency` work properly through structural types like
arrays, optionals, and dictionaries.
While here, also check whether the nominal declaration itself has been
marked as `@preconcurrency`.
Fixes rdar://125081249.
// expected-swift-5-no-tns-warning @-1 {{passing argument of non-sendable type 'PreCUncheckedExplicitlyNonSendableKlass' (aka 'ExplicitlyNonSendableKlass') into main actor-isolated context may introduce data races}}
66
-
// expected-swift-5-warning @-2 {{sending 'x' risks causing data races}}
67
-
// expected-swift-5-note @-3 {{sending 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
68
-
// expected-swift-6-warning @-4 {{sending 'x' risks causing data races}}
69
-
// expected-swift-6-note @-5 {{sending 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
62
+
// expected-swift-5-warning @-1 {{sending 'x' risks causing data races}}
63
+
// expected-swift-5-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
64
+
// expected-swift-6-warning @-3 {{sending 'x' risks causing data races}}
65
+
// expected-swift-6-note @-4 {{sending 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
70
66
useValue(x)
71
67
// expected-swift-5-note @-1 {{access can happen concurrently}}
72
68
// expected-swift-6-note @-2 {{access can happen concurrently}}
// In swift 5 this is a warning and in swift 6 this is an error.
76
72
func testNormal()async{
77
73
letx=PostCUncheckedNonSendableKlass()
78
-
awaittransferToMain(x) // expected-swift-5-no-tns-warning {{passing argument of non-sendable type 'PostCUncheckedNonSendableKlass' (aka 'NonSendableKlass') into main actor-isolated context may introduce data races}}
74
+
awaittransferToMain(x)
79
75
// expected-swift-5-warning @-1 {{sending 'x' risks causing data races}}
80
76
// expected-swift-6-error @-2 {{sending 'x' risks causing data races}}
81
77
// expected-swift-5-note @-3 {{sending 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
// We would squelch this if we transferred it directly. Also we error even
91
87
// though we use x later.
92
88
awaittransferToMain(y)
93
-
// expected-swift-5-no-tns-warning @-1 2{{passing argument of non-sendable type '(PreCUncheckedNonSendableKlass, PreCUncheckedNonSendableKlass)' (aka '(NonSendableKlass, NonSendableKlass)') into main actor-isolated context may introduce data races}}
94
-
// expected-swift-5-warning @-2 {{sending 'y' risks causing data races}}
95
-
// expected-swift-5-note @-3 {{sending 'y' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
96
-
// expected-swift-6-error @-4 {{sending 'y' risks causing data races}}
97
-
// expected-swift-6-note @-5 {{sending 'y' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
89
+
// expected-swift-5-warning @-1 {{sending 'y' risks causing data races}}
90
+
// expected-swift-5-note @-2 {{sending 'y' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
91
+
// expected-swift-6-error @-3 {{sending 'y' risks causing data races}}
92
+
// expected-swift-6-note @-4 {{sending 'y' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
98
93
useValue(x)
99
94
// expected-swift-5-note @-1 {{access can happen concurrently}}
100
95
// expected-swift-6-note @-2 {{access can happen concurrently}}
awaittransferToMain(x) // expected-swift-5-no-tns-warning {{passing argument of non-sendable type 'PreCUncheckedExplicitlyNonSendableKlass' (aka 'ExplicitlyNonSendableKlass') into main actor-isolated context may introduce data races}}
115
+
awaittransferToMain(x)
121
116
// expected-swift-5-warning @-1 {{sending 'x' risks causing data races}}
122
117
// expected-swift-5-note @-2 {{sending task-isolated 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and task-isolated uses}}
123
118
// expected-swift-6-warning @-3 {{sending 'x' risks causing data races}}
124
119
// expected-swift-6-note @-4 {{sending task-isolated 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and task-isolated uses}}
awaittransferToMain(x) // expected-swift-5-no-tns-warning {{passing argument of non-sendable type 'PostCUncheckedNonSendableKlass' (aka 'NonSendableKlass') into main actor-isolated context may introduce data races}}
123
+
awaittransferToMain(x)
129
124
// expected-swift-5-warning @-1 {{sending 'x' risks causing data races}}
130
125
// expected-swift-5-note @-2 {{sending task-isolated 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and task-isolated uses}}
131
126
// expected-swift-6-error @-3 {{sending 'x' risks causing data races}}
awaittransferToMain(x) // expected-swift-5-no-tns-warning 2{{passing argument of non-sendable type '(PreCUncheckedNonSendableKlass, PreCUncheckedNonSendableKlass)' (aka '(NonSendableKlass, NonSendableKlass)') into main actor-isolated context may introduce data races}}
132
+
awaittransferToMain(x)
138
133
// expected-swift-5-warning @-1 {{sending 'x' risks causing data races}}
139
134
// expected-swift-5-note @-2 {{sending task-isolated 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and task-isolated uses}}
140
135
// expected-swift-6-error @-3 {{sending 'x' risks causing data races}}
awaittransferToMain(x) // expected-swift-5-no-tns-warning {{passing argument of non-sendable type '(PreCUncheckedExplicitlyNonSendableKlass, PreCUncheckedExplicitlyNonSendableKlass)' (aka '(ExplicitlyNonSendableKlass, ExplicitlyNonSendableKlass)') into main actor-isolated context may introduce data races}}
141
+
awaittransferToMain(x)
147
142
// expected-swift-5-warning @-1 {{sending 'x' risks causing data races}}
148
143
// expected-swift-5-note @-2 {{sending task-isolated 'x' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and task-isolated uses}}
149
144
// expected-swift-6-error @-3 {{sending 'x' risks causing data races}}
0 commit comments