mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for deployment to the minimum OS versions required for use of _Concurrency APIs, instead of disabling availability checking.
18 lines
843 B
Swift
18 lines
843 B
Swift
// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple
|
|
|
|
// We could make this work by having `lazy` synthesize an effectful
|
|
// getter, but for now let's reject it instead of crashing.
|
|
|
|
func throwsFunc() throws -> Int { return 3 }
|
|
func asyncFunc() async -> Int { return 3 }
|
|
|
|
func localLazyWithEffects() {
|
|
lazy var x = try throwsFunc() // expected-error {{call can throw, but errors cannot be thrown out of a lazy variable initializer}}
|
|
lazy var y = await asyncFunc() // expected-error {{'async' call cannot occur in a lazy variable initializer}}
|
|
}
|
|
|
|
struct InstanceLazyWithEffects {
|
|
lazy var x = try throwsFunc() // expected-error {{call can throw, but errors cannot be thrown out of a property initializer}}
|
|
lazy var y = await asyncFunc() // expected-error {{'async' call cannot occur in a property initializer}}
|
|
}
|