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
Merge pull request swiftlang#72247 from gottesmm/diagnostic-improvements
[region-isolation] Change "pass non-transferable non-sendable value as transferring parameter" error to use the variables name + some other small improvements
func testAsyncSequenceTypedPattern<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{54-54=, Sendable}}
29
-
asyncletresult:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
29
+
asyncletresult:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{task or actor isolated value cannot be transferred}}
30
30
// expected-warning @-1 {{immutable value 'result' was never used; consider replacing with '_' or removing it}}
31
31
// expected-targeted-and-complete-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
32
32
}
33
33
34
34
func testAsyncSequenceTypedPattern1<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{55-55=, Sendable}}
35
-
asynclet _:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
35
+
asynclet _:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{task or actor isolated value cannot be transferred}}
36
36
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
37
37
}
38
38
39
39
func testAsyncSequence<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{42-42=, Sendable}}
40
-
asyncletresult= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
40
+
asyncletresult= seq.reduce(0){ $0 + $1 } // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
41
41
// expected-warning @-1 {{initialization of immutable value 'result' was never used; consider replacing with assignment to '_' or removing it}}
42
42
// expected-targeted-and-complete-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
43
43
}
44
44
45
45
func testAsyncSequence1<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{43-43=, Sendable}}
46
-
asynclet _ = seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
46
+
asynclet _ = seq.reduce(0){ $0 + $1 } // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
47
47
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
48
48
}
49
49
50
50
func testAsyncSequence3<Seq>(_ seq:Seq)asyncthrowswhere Seq:AsyncSequence, Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
51
-
asyncletresult= seq // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
51
+
asyncletresult= seq // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
52
52
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
53
53
//expected-warning @-2 {{initialization of immutable value 'result' was never used; consider replacing with assignment to '_' or removing it}}
54
54
}
55
55
56
56
func testAsyncSequence4<Seq>(_ seq:Seq)asyncthrowswhere Seq:AsyncSequence, Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
57
-
asynclet _ = seq // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
57
+
asynclet _ = seq // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
58
58
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
awaittransferToCustom(x) // expected-warning {{transferring 'x' may cause a race}}
364
+
// expected-note @-1 {{transferring main actor-isolated 'x' to global actor 'CustomActor'-isolated callee could cause races between global actor 'CustomActor'-isolated and main actor-isolated uses}}
0 commit comments