|
1 | 1 | // RUN: %empty-directory(%t)
|
2 | 2 |
|
3 |
| -// RUN: %target-swift-frontend -I %t -disable-availability-checking -strict-concurrency=complete -enable-upcoming-feature IsolatedDefaultValues -parse-as-library -emit-sil -o /dev/null -verify %s |
4 |
| -// RUN: %target-swift-frontend -I %t -disable-availability-checking -strict-concurrency=complete -parse-as-library -emit-sil -o /dev/null -verify -enable-upcoming-feature IsolatedDefaultValues -enable-upcoming-feature RegionBasedIsolation %s |
| 3 | +// RUN: %target-swift-frontend -I %t -disable-availability-checking -strict-concurrency=complete -parse-as-library -emit-sil -o /dev/null -verify -enable-upcoming-feature IsolatedDefaultValues -enable-upcoming-feature RegionBasedIsolation -enable-upcoming-feature InferSendableFromCaptures %s |
5 | 4 |
|
6 | 5 | // REQUIRES: concurrency
|
7 | 6 | // REQUIRES: asserts
|
@@ -282,3 +281,39 @@ struct InitAccessors {
|
282 | 281 | struct CError: Error, RawRepresentable {
|
283 | 282 | var rawValue: CInt
|
284 | 283 | }
|
| 284 | + |
| 285 | +// Consider isolated key-paths when computing initializer isolation |
| 286 | + |
| 287 | +@MainActor |
| 288 | +class UseIsolatedKeyPath { |
| 289 | + let kp: KeyPath<UseIsolatedKeyPath, Nested> = \.x // okay |
| 290 | + |
| 291 | + // expected-error@+1 {{default argument cannot be both main actor-isolated and global actor 'SomeGlobalActor'-isolated}} |
| 292 | + let kp2: KeyPath<UseIsolatedKeyPath, Bool> = \.x.y // okay |
| 293 | + |
| 294 | + var x: Nested = .init() |
| 295 | + |
| 296 | + class Nested { |
| 297 | + @SomeGlobalActor var y: Bool = true |
| 298 | + } |
| 299 | +} |
| 300 | + |
| 301 | +@MainActor |
| 302 | +protocol InferMainActor {} |
| 303 | + |
| 304 | +struct UseIsolatedPropertyWrapperInit: InferMainActor { |
| 305 | + @Wrapper(\.value) var value: Int // okay |
| 306 | + |
| 307 | + // expected-warning@+1 {{global actor 'SomeGlobalActor'-isolated default value in a main actor-isolated context; this is an error in the Swift 6 language mode}} |
| 308 | + @Wrapper(\.otherValue) var otherValue: Int |
| 309 | +} |
| 310 | + |
| 311 | +@propertyWrapper struct Wrapper<T> { |
| 312 | + init(_: KeyPath<Values, T>) {} |
| 313 | + var wrappedValue: T { fatalError() } |
| 314 | +} |
| 315 | + |
| 316 | +struct Values { |
| 317 | + @MainActor var value: Int { 0 } |
| 318 | + @SomeGlobalActor var otherValue: Int { 0 } |
| 319 | +} |
0 commit comments