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
[region-isolation] When printing a SILIsolationInfo description for diagnostics, if we have a SIL actor instance, print -isolated instead of actor-isolated.
%6 = apply [caller_isolation=nonisolated] [callee_isolation=actor_instance] %5(%4) : $@convention(method) @async (@guaranteed NonSendableKlass) -> () // expected-warning {{actor-isolated value of type 'NonSendableKlass' transferred to actor-isolated context; later accesses to value could race}}
295
+
%6 = apply [caller_isolation=nonisolated] [callee_isolation=actor_instance] %5(%4) : $@convention(method) @async (@guaranteed NonSendableKlass) -> () // expected-warning {{'self'-isolated value of type 'NonSendableKlass' transferred to actor-isolated context; later accesses to value could race}}
%14 = apply [caller_isolation=actor_instance] [callee_isolation=global_actor] %13<NonSendableKlass>(%12) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-warning {{actor-isolated value of type 'NonSendableKlass' transferred to global actor '<null>'-isolated context}}
316
+
%14 = apply [caller_isolation=actor_instance] [callee_isolation=global_actor] %13<NonSendableKlass>(%12) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-warning {{'self'-isolated value of type 'NonSendableKlass' transferred to global actor '<null>'-isolated context}}
Copy file name to clipboardExpand all lines: test/Concurrency/transfernonsendable.swift
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -83,14 +83,14 @@ extension Actor {
83
83
func warningIfCallingGetter()async{
84
84
awaitself.klass.asyncCall() // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' outside of actor-isolated context may introduce data races}}
85
85
// expected-tns-warning @-1 {{transferring 'self.klass' may cause a data race}}
86
-
// expected-tns-note @-2 {{transferring actor-isolated 'self.klass' to nonisolated callee could cause races between nonisolated and actor-isolated uses}}
86
+
// expected-tns-note @-2 {{transferring 'self'-isolated 'self.klass' to nonisolated callee could cause races between nonisolated and 'self'-isolated uses}}
87
87
}
88
88
89
89
func warningIfCallingAsyncOnFinalField()async{
90
90
// Since we are calling finalKlass directly, we emit a warning here.
91
91
awaitself.finalKlass.asyncCall() // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' outside of actor-isolated context may introduce data races}}
92
92
// expected-tns-warning @-1 {{transferring 'self.finalKlass' may cause a data race}}
93
-
// expected-tns-note @-2 {{transferring actor-isolated 'self.finalKlass' to nonisolated callee could cause races between nonisolated and actor-isolated uses}}
93
+
// expected-tns-note @-2 {{transferring 'self'-isolated 'self.finalKlass' to nonisolated callee could cause races between nonisolated and 'self'-isolated uses}}
94
94
}
95
95
96
96
// We do not warn on this since we warn in the caller of our getter instead.
@@ -104,7 +104,7 @@ extension FinalActor {
104
104
// Since our whole class is final, we emit the error directly here.
105
105
awaitself.klass.asyncCall() // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' outside of actor-isolated context may introduce data races}}
106
106
// expected-tns-warning @-1 {{transferring 'self.klass' may cause a data race}}
107
-
// expected-tns-note @-2 {{transferring actor-isolated 'self.klass' to nonisolated callee could cause races between nonisolated and actor-isolated uses}}
107
+
// expected-tns-note @-2 {{transferring 'self'-isolated 'self.klass' to nonisolated callee could cause races between nonisolated and 'self'-isolated uses}}
108
108
}
109
109
}
110
110
@@ -401,7 +401,7 @@ extension Actor {
401
401
awaittransferToMain(closure) // expected-complete-warning {{passing argument of non-sendable type '() -> ()' into main actor-isolated context may introduce data races}}
402
402
// expected-complete-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
403
403
// expected-tns-warning @-2 {{transferring 'closure' may cause a data race}}
404
-
// expected-tns-note @-3 {{transferring actor-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
404
+
// expected-tns-note @-3 {{transferring 'self'-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
awaittransferToMain(closure) // expected-complete-warning {{passing argument of non-sendable type '() -> ()' into main actor-isolated context may introduce data races}}
413
413
// expected-complete-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
414
414
// expected-tns-warning @-2 {{transferring 'closure' may cause a data race}}
415
-
// expected-tns-note @-3 {{transferring actor-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
415
+
// expected-tns-note @-3 {{transferring 'self'-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
awaittransferToMain(closure) // expected-complete-warning {{passing argument of non-sendable type '() -> ()' into main actor-isolated context may introduce data races}}
424
424
// expected-complete-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
425
425
// expected-tns-warning @-2 {{transferring 'closure' may cause a data race}}
426
-
// expected-tns-note @-3 {{transferring actor-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
426
+
// expected-tns-note @-3 {{transferring 'self'-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
427
427
}
428
428
}
429
429
@@ -512,7 +512,7 @@ extension Actor {
512
512
awaittransferToMain(closure) // expected-complete-warning {{passing argument of non-sendable type '() -> ()' into main actor-isolated context may introduce data races}}
513
513
// expected-complete-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
514
514
// expected-tns-warning @-2 {{transferring 'closure' may cause a data race}}
515
-
// expected-tns-note @-3 {{transferring actor-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
515
+
// expected-tns-note @-3 {{transferring 'self'-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
516
516
}
517
517
518
518
// Make sure that we properly propagate actor derived from klass into field's
@@ -525,7 +525,7 @@ extension Actor {
525
525
awaittransferToMain(closure) // expected-complete-warning {{passing argument of non-sendable type '() -> ()' into main actor-isolated context may introduce data races}}
526
526
// expected-complete-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
527
527
// expected-tns-warning @-2 {{transferring 'closure' may cause a data race}}
528
-
// expected-tns-note @-3 {{transferring actor-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
528
+
// expected-tns-note @-3 {{transferring 'self'-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
529
529
}
530
530
}
531
531
@@ -1439,23 +1439,23 @@ actor ActorWithSetter {
1439
1439
letx=NonSendableKlass()
1440
1440
self.field = x
1441
1441
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1442
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1442
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1443
1443
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1444
1444
}
1445
1445
1446
1446
func test2()async{
1447
1447
letx=NonSendableKlass()
1448
1448
self.twoFieldBox.k1 = x
1449
1449
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1450
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1450
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1451
1451
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1452
1452
}
1453
1453
1454
1454
func test3()async{
1455
1455
letx=NonSendableKlass()
1456
1456
self.twoFieldBoxInTuple.1.k1 = x
1457
1457
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1458
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1458
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1459
1459
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1460
1460
}
1461
1461
@@ -1476,7 +1476,7 @@ actor ActorWithSetter {
1476
1476
letx=NonSendableKlass()
1477
1477
self.classBox.k1 = x
1478
1478
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1479
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1479
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1480
1480
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1481
1481
}
1482
1482
}
@@ -1492,23 +1492,23 @@ final actor FinalActorWithSetter {
1492
1492
letx=NonSendableKlass()
1493
1493
self.field = x
1494
1494
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1495
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1495
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1496
1496
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1497
1497
}
1498
1498
1499
1499
func test2()async{
1500
1500
letx=NonSendableKlass()
1501
1501
self.twoFieldBox.k1 = x
1502
1502
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1503
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1503
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1504
1504
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1505
1505
}
1506
1506
1507
1507
func test3()async{
1508
1508
letx=NonSendableKlass()
1509
1509
self.twoFieldBoxInTuple.1.k1 = x
1510
1510
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1511
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1511
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1512
1512
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1513
1513
}
1514
1514
@@ -1529,7 +1529,7 @@ final actor FinalActorWithSetter {
1529
1529
letx=NonSendableKlass()
1530
1530
self.classBox.k1 = x
1531
1531
awaittransferToMain(x) // expected-tns-warning {{transferring 'x' may cause a data race}}
1532
-
// expected-tns-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
1532
+
// expected-tns-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
1533
1533
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
awaittransferToMain(x) // expected-warning {{transferring 'x' may cause a data race}}
163
-
// expected-note @-1 {{transferring actor-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
163
+
// expected-note @-1 {{transferring 'self'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and 'self'-isolated uses}}
0 commit comments