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
There were some tests that relied on the top-level code not being an
asynchronous context to emit certain error messages. Now that it is,
those tests weren't emitting the expected error message.
In other cases, the issue was that they were trying to initialize a
global variable and weren't really using top-level code as top-level
code, so adding `-parse-as-library` was sufficient for the testing
purposes.
To fix the objc_async test, parsing as a library was nearly sufficient.
Unfortunately, the little `if #available` trick that I was using stopped
working since it relied on being in top-level code. So that we emit the
unavailableFromAsync error message, I had to set the availability on
everything correctly because we can't just disable availability
checking.
let _:Int= slowServer.overridableButRunsOnMainThread // expected-error{{cannot convert value of type '(((String) -> Void)?) -> Void' to specified type 'Int'}}
// Check inferred isolation for overridden decls from ObjC.
238
254
// Note that even if the override is not present, it
239
255
// can have an affect. -- rdar://87217618 / SR-15694
240
256
@MainActor
257
+
@available(SwiftStdlib 5.5,*)
241
258
classFooFrame:PictureFrame{
242
259
init(){
243
260
super.init(size:0)
@@ -252,6 +269,7 @@ class FooFrame: PictureFrame {
252
269
}
253
270
}
254
271
272
+
@available(SwiftStdlib 5.5,*)
255
273
classBarFrame:PictureFrame{
256
274
init(){
257
275
super.init(size:0)
@@ -266,6 +284,7 @@ class BarFrame: PictureFrame {
266
284
}
267
285
}
268
286
287
+
@available(SwiftStdlib 5.5,*)
269
288
@SomeGlobalActor
270
289
classBazFrame:NotIsolatedPictureFrame{
271
290
init(){
@@ -285,6 +304,7 @@ class BazFrame: NotIsolatedPictureFrame {
285
304
classBazFrameIso:PictureFrame{ // expected-error {{global actor 'SomeGlobalActor'-isolated class 'BazFrameIso' has different actor isolation from main actor-isolated superclass 'PictureFrame'}}
Copy file name to clipboardExpand all lines: test/Concurrency/property_initializers_swift6.swift
+12-8Lines changed: 12 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,21 @@
3
3
4
4
// REQUIRES: asserts
5
5
6
-
@MainActor
7
-
func mainActorFn()->Int{return0} // expected-note 2 {{calls to global function 'mainActorFn()' from outside of its actor context are implicitly asynchronous}}
6
+
@globalActor
7
+
actorGlobalActor{
8
+
staticletshared=GlobalActor()
9
+
}
10
+
11
+
@GlobalActor
12
+
func globalActorFn()->Int{return0} // expected-note 2 {{calls to global function 'globalActorFn()' from outside of its actor context are implicitly asynchronous}}
8
13
9
-
@MainActor
14
+
@GlobalActor
10
15
classC{
11
-
varx:Int=mainActorFn() // expected-error {{call to main actor-isolated global function 'mainActorFn()' in a synchronous nonisolated context}}
16
+
varx:Int=globalActorFn() // expected-error {{call to global actor 'GlobalActor'-isolated global function 'globalActorFn()' in a synchronous nonisolated context}}
12
17
13
-
lazy vary:Int=mainActorFn()
18
+
lazy vary:Int=globalActorFn()
14
19
15
-
staticvarz:Int=mainActorFn()
20
+
staticvarz:Int=globalActorFn()
16
21
}
17
22
18
-
@MainActor
19
-
varx:Int=mainActorFn() // expected-error {{call to main actor-isolated global function 'mainActorFn()' in a synchronous nonisolated context}}
23
+
varx:Int=globalActorFn() // expected-error {{call to global actor 'GlobalActor'-isolated global function 'globalActorFn()' in a synchronous main actor-isolated context}}
0 commit comments