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
overridefunc runsInForeground(_:@Sendable()->Void){} // expected-warning {{declaration 'runsInForeground' has a type with different sendability from any potential overrides; this is an error in Swift 6}}
139
+
overridefunc runnableInBackground()->()->Void{fatalError()} // expected-warning {{declaration 'runnableInBackground()' has a type with different sendability from any potential overrides; this is an error in Swift 6}}
func runsInForeground(_:()->Void) // expected-note {{expected sendability to match requirement here}}
146
+
func runnableInBackground()->@Sendable()->Void // expected-note {{expected sendability to match requirement here}}
147
+
func runnableInForeground()->()->Void
148
+
}
149
+
150
+
structConcreteSendable:AbstractSendable{
151
+
func runsInBackground(_:()->Void){}
152
+
func runsInForeground(_:@Sendable()->Void){} // expected-warning {{sendability of function types in instance method 'runsInForeground' does not match requirement in protocol 'AbstractSendable'; this is an error in Swift 6}}
153
+
func runnableInBackground()->()->Void{fatalError()} // expected-warning {{sendability of function types in instance method 'runnableInBackground()' does not match requirement in protocol 'AbstractSendable'; this is an error in Swift 6}}
Copy file name to clipboardExpand all lines: test/decl/protocol/conforms/associated_type.swift
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ class Foo: FooType {
37
37
protocolP1{
38
38
associatedtypeA
39
39
40
-
func f(_:A) // expected-note {{protocol requires function 'f' with type '(@escaping SendableX1b.A) -> ()' (aka '(@escaping @Sendable (Int) -> Int) -> ()'); do you want to add a stub?}}
40
+
func f(_:A) // expected-note {{expected sendability to match requirement here}}
41
41
}
42
42
43
43
structX1a:P1{
@@ -61,10 +61,10 @@ struct X1b : P1 {
61
61
// instead of adjusting types before adding them to the constraint
62
62
// graph, we should introduce a new constraint kind that allows only a
63
63
// witness's adjustments.
64
-
structSendableX1b:P1{ // expected-error {{type 'SendableX1b' does not conform to protocol 'P1'}}
64
+
structSendableX1b:P1{
65
65
typealiasA=@Sendable(Int)->Int
66
66
67
-
func f(_:(Int)->Int){} // expected-note {{candidate has non-matching type '((Int) -> Int) -> ()'}}
67
+
func f(_:(Int)->Int){} // expected-warning {{sendability of function types in instance method 'f' does not match requirement in protocol 'P1'; this is an error in Swift 6}}
68
68
}
69
69
70
70
structX1c:P1{
@@ -78,8 +78,8 @@ struct X1d : P1 {
78
78
}
79
79
80
80
protocolP2{
81
-
func f(_:(Int)->Int) // expected-note 3 {{protocol requires function 'f' with type '((Int) -> Int) -> ()'; do you want to add a stub?}}
82
-
func g(_:@escaping(Int)->Int) // expected-note 2 {{protocol requires function 'g' with type '(@escaping (Int) -> Int) -> ()'; do you want to add a stub?}}
81
+
func f(_:(Int)->Int) // expected-note{{expected sendability to match requirement here}} expected-note 2{{protocol requires function 'f' with type '((Int) -> Int) -> ()'; do you want to add a stub?}}
82
+
func g(_:@escaping(Int)->Int) // expected-note 2 {{expected sendability to match requirement here}}
83
83
func h(_:@Sendable(Int)->Int) // expected-note 2 {{protocol requires function 'h' with type '(@Sendable (Int) -> Int) -> ()'; do you want to add a stub?}}
84
84
func i(_:@escaping@Sendable(Int)->Int)
85
85
}
@@ -98,16 +98,16 @@ struct X2b : P2 { // expected-error{{type 'X2b' does not conform to protocol 'P2
98
98
func i(_:@escaping(Int)->Int){}
99
99
}
100
100
101
-
structX2c:P2{ // expected-error{{type 'X2c' does not conform to protocol 'P2'}}
102
-
func f(_:@Sendable(Int)->Int){} // expected-note{{candidate has non-matching type '(@Sendable (Int) -> Int) -> ()'}}
103
-
func g(_:@Sendable(Int)->Int){} // expected-note{{candidate has non-matching type '(@Sendable (Int) -> Int) -> ()'}}
101
+
structX2c:P2{
102
+
func f(_:@Sendable(Int)->Int){} // expected-warning{{sendability of function types in instance method 'f' does not match requirement in protocol 'P2'; this is an error in Swift 6}}
103
+
func g(_:@Sendable(Int)->Int){} // expected-warning{{sendability of function types in instance method 'g' does not match requirement in protocol 'P2'; this is an error in Swift 6}}
104
104
func h(_:@Sendable(Int)->Int){}
105
105
func i(_:@Sendable(Int)->Int){}
106
106
}
107
107
108
108
structX2d:P2{ // expected-error{{type 'X2d' does not conform to protocol 'P2'}}
109
109
func f(_:@escaping@Sendable(Int)->Int){} // expected-note{{candidate has non-matching type '(@escaping @Sendable (Int) -> Int) -> ()'}}
110
-
func g(_:@escaping@Sendable(Int)->Int){} // expected-note{{candidate has non-matching type '(@escaping @Sendable (Int) -> Int) -> ()'}}
110
+
func g(_:@escaping@Sendable(Int)->Int){} // expected-warning{{sendability of function types in instance method 'g' does not match requirement in protocol 'P2'; this is an error in Swift 6}}
111
111
func h(_:@escaping@Sendable(Int)->Int){} // expected-note{{candidate has non-matching type '(@escaping @Sendable (Int) -> Int) -> ()'}}
0 commit comments