mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
"Function builders" are being renamed to "result builders". Add the corresponding `@resultBuilder` attribute, with `@_functionBuilder` as an alias for it, Update test cases to use @resultBuilder.
44 lines
963 B
Swift
44 lines
963 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
struct Result {}
|
|
|
|
@resultBuilder
|
|
struct Builder {
|
|
static func buildBlock() -> Result {
|
|
Result()
|
|
}
|
|
}
|
|
|
|
func test_builder<T>(@Builder _: () -> T) {}
|
|
func test_builder(@Builder _: () -> Int) {}
|
|
|
|
test_builder {
|
|
let _ = 0
|
|
|
|
if let x = does_not_exist { // expected-error {{cannot find 'does_not_exist' in scope}}
|
|
}
|
|
}
|
|
|
|
func test(_: Int) -> Bool {
|
|
return false
|
|
}
|
|
|
|
test_builder {
|
|
let totalSeconds = 42000
|
|
test(totalseconds / 3600) // expected-error {{cannot find 'totalseconds' in scope}}
|
|
}
|
|
|
|
test_builder {
|
|
test(doesntExist()) // expected-error {{cannot find 'doesntExist' in scope}}
|
|
|
|
if let result = doesntExist() { // expected-error {{cannot find 'doesntExist' in scope}}
|
|
}
|
|
|
|
if bar = test(42) {} // expected-error {{cannot find 'bar' in scope}}
|
|
|
|
let foo = bar() // expected-error {{cannot find 'bar' in scope}}
|
|
|
|
switch (doesntExist()) { // expected-error {{cannot find 'doesntExist' in scope}}
|
|
}
|
|
}
|