|
61 | 61 |
|
62 | 62 | let _: KeyPath<K, Bool> = \.[NonSendable()] // ok
|
63 | 63 | let _: KeyPath<K, Bool> & Sendable = \.[NonSendable()] // expected-warning {{type 'KeyPath<K, Bool>' does not conform to the 'Sendable' protocol}}
|
64 |
| - let _: KeyPath<K, Int> & Sendable = \.[42, NonSendable(data: [-1, 0, 1])] // expected-warning {{type 'ReferenceWritableKeyPath<K, Int>' does not conform to the 'Sendable' protocol}} |
| 64 | + let _: KeyPath<K, Int> & Sendable = \.[42, NonSendable(data: [-1, 0, 1])] // expected-warning {{type 'KeyPath<K, Int>' does not conform to the 'Sendable' protocol}} |
65 | 65 | let _: KeyPath<K, Int> & Sendable = \.[42, -1] // Ok
|
66 | 66 |
|
67 | 67 | test(nonSendableKP) // expected-warning {{type 'KeyPath<K, Bool>' does not conform to the 'Sendable' protocol}}
|
@@ -106,22 +106,22 @@ do {
|
106 | 106 | // expected-warning@-1 {{converting non-Sendable function value to '@Sendable (V) -> Int' may introduce data races}}
|
107 | 107 |
|
108 | 108 | let _: KeyPath<V, Int> & Sendable = \.[42, CondSendable(NonSendable(data: [1, 2, 3]))]
|
109 |
| - // expected-warning@-1 {{type 'ReferenceWritableKeyPath<V, Int>' does not conform to the 'Sendable' protocol}} |
| 109 | + // expected-warning@-1 {{type 'KeyPath<V, Int>' does not conform to the 'Sendable' protocol}} |
110 | 110 | let _: KeyPath<V, Int> & Sendable = \.[42, CondSendable(42)] // Ok
|
111 | 111 |
|
112 | 112 | struct Root {
|
113 | 113 | let v: V
|
114 | 114 | }
|
115 | 115 |
|
116 | 116 | testSendableKP(v: v, \.[42, CondSendable(NonSendable(data: [1, 2, 3]))])
|
117 |
| - // expected-warning@-1 {{type 'ReferenceWritableKeyPath<V, Int>' does not conform to the 'Sendable' protocol}} |
| 117 | + // expected-warning@-1 {{type 'KeyPath<V, Int>' does not conform to the 'Sendable' protocol}} |
118 | 118 | testSendableFn(v: v, \.[42, CondSendable(NonSendable(data: [1, 2, 3]))])
|
119 | 119 | // expected-warning@-1 {{converting non-Sendable function value to '@Sendable (V) -> Int' may introduce data races}}
|
120 | 120 | testSendableKP(v: v, \.[42, CondSendable(42)]) // Ok
|
121 | 121 |
|
122 | 122 | let nonSendable = NonSendable()
|
123 | 123 | testSendableKP(v: v, \.[42, CondSendable(nonSendable)])
|
124 |
| - // expected-warning@-1 {{type 'ReferenceWritableKeyPath<V, Int>' does not conform to the 'Sendable' protocol}} |
| 124 | + // expected-warning@-1 {{type 'KeyPath<V, Int>' does not conform to the 'Sendable' protocol}} |
125 | 125 |
|
126 | 126 | testSendableFn(v: v, \.[42, CondSendable(nonSendable)])
|
127 | 127 | // expected-warning@-1 {{converting non-Sendable function value to '@Sendable (V) -> Int' may introduce data races}}
|
@@ -277,3 +277,14 @@ do {
|
277 | 277 | // expected-warning@-1 {{type 'KeyPath<Foo, Int>' does not conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode}}
|
278 | 278 | }
|
279 | 279 | }
|
| 280 | + |
| 281 | +public final class TestSetterRef { |
| 282 | + public internal(set) var v: Int = 0 // expected-note {{setter for property 'v' is not '@usableFromInline' or public}} |
| 283 | + |
| 284 | + public func test1(_ kp: KeyPath<TestSetterRef, Int> = \.v) {} // Ok |
| 285 | + public func test2(_ kp: KeyPath<TestSetterRef, Int> = \TestSetterRef.v) {} // Ok |
| 286 | + public func test3(_ kp: KeyPath<TestSetterRef, Int> & Sendable = \.v) {} // Ok |
| 287 | + |
| 288 | + public func test_err(_ kp: WritableKeyPath<TestSetterRef, Int> = \.v) {} |
| 289 | + // expected-warning@-1 {{setter for property 'v' is internal and should not be referenced from a default argument value}} |
| 290 | +} |
0 commit comments