mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Find all the usages of `--enable-experimental-feature` or `--enable-upcoming-feature` in the tests and replace some of the `REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which should correctly apply to depending on the asserts/noasserts mode of the toolchain for each feature. Remove some comments that talked about enabling asserts since they don't apply anymore (but I might had miss some). All this was done with an automated script, so some formatting weirdness might happen, but I hope I fixed most of those. There might be some tests that were `REQUIRES: asserts` that might run in `noasserts` toolchains now. This will normally be because their feature went from experimental to upcoming/base and the tests were not updated.
71 lines
1.2 KiB
Swift
71 lines
1.2 KiB
Swift
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ParserASTGen -DDISCARDABLE -DNONSENDABLE -swift-version 6
|
|
|
|
// REQUIRES: swift_feature_ParserASTGen
|
|
|
|
#if NOT_SET
|
|
func f { } // expected-error{{expected parameter clause in function signature}}
|
|
// expected-note@-1{{insert parameter clause}}{{7-8=}}{{8-8=(}}{{8-8=) }}
|
|
#endif
|
|
|
|
#if compiler(>=10.0)
|
|
bad code is not diagnosed
|
|
#endif
|
|
|
|
#if canImport(NoSuchModule)
|
|
func g() { }
|
|
#else
|
|
func h() { }
|
|
#endif
|
|
|
|
|
|
func testH() {
|
|
h()
|
|
}
|
|
|
|
// Declaration attributes
|
|
#if DISCARDABLE
|
|
@discardableResult
|
|
#endif
|
|
func ignorable() -> Int { 5 }
|
|
|
|
|
|
func testIgnorable() {
|
|
ignorable() // no warning
|
|
}
|
|
|
|
// Type attributes
|
|
// FIXME: Something isn't getting converted properly when I try to put an #if
|
|
// within the type attributes.
|
|
typealias CallbackType = () -> Void
|
|
|
|
func acceptMaybeSendable(body: CallbackType) { }
|
|
|
|
func testMaybeSendable() {
|
|
var x = 10
|
|
acceptMaybeSendable {
|
|
x += 1
|
|
}
|
|
print(x)
|
|
}
|
|
|
|
// Switch cases
|
|
enum SafetyError: Error {
|
|
case unsafe
|
|
|
|
#if NONSENDABLE
|
|
case nonSendable
|
|
#endif
|
|
}
|
|
|
|
extension SafetyError {
|
|
var description: String {
|
|
switch self {
|
|
case .unsafe: "unsafe"
|
|
|
|
#if NONSENDABLE
|
|
case .nonSendable: "non-sendable"
|
|
#endif
|
|
}
|
|
}
|
|
}
|