mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
If `buildBlock` is also unavailable, or the builder itself is unavailable, continue to solve using `buildPartialBlock` to get better diagnostics. This behavior technically differs from what is specified in SE-0348, but only affects the invalid case where no builder methods are available to use. In particular, this improves diagnostics for RegexComponentBuilder when the deployment target is too low. Previously we would try to solve using `buildBlock` (as `buildPartialBlock` is unavailable), but RegexComponentBuilder only defines `buildBlock` for the empty body case, leading to unhelpful diagnostics that ultimately preferred not to use the result builder at all. rdar://97533700
29 lines
1.3 KiB
Swift
29 lines
1.3 KiB
Swift
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -target %target-cpu-apple-macosx12.0
|
||
|
||
// REQUIRES: OS=macosx
|
||
|
||
import RegexBuilder
|
||
|
||
// rdar://97533700 – Make sure we can emit an availability diagnostic here.
|
||
|
||
let _ = Regex { // expected-error {{'Regex' is only available in macOS 13.0 or newer}}
|
||
// expected-error@-1 {{'init(_:)' is only available in macOS 13.0 or newer}}
|
||
// expected-note@-2 2{{add 'if #available' version check}}
|
||
|
||
Capture {} // expected-error {{'Capture' is only available in macOS 13.0 or newer}}
|
||
// expected-error@-1 {{'init(_:)' is only available in macOS 13.0 or newer}}
|
||
// expected-note@-2 2{{add 'if #available' version check}}
|
||
}
|
||
|
||
let _ = Regex { // expected-error {{'Regex' is only available in macOS 13.0 or newer}}
|
||
// expected-error@-1 {{'init(_:)' is only available in macOS 13.0 or newer}}
|
||
// expected-error@-2 {{'buildPartialBlock(accumulated:next:)' is only available in macOS 13.0 or newer}}
|
||
// expected-note@-3 3{{add 'if #available' version check}}
|
||
|
||
/abc/ // expected-error {{'Regex' is only available in macOS 13.0 or newer}}
|
||
// expected-note@-1 {{add 'if #available' version check}}
|
||
|
||
/def/ // expected-error {{'Regex' is only available in macOS 13.0 or newer}}
|
||
// expected-note@-1 {{add 'if #available' version check}}
|
||
}
|