mirror of
https://github.com/apple/swift.git
synced 2026-10-28 21:15:56 +01:00
An expectation like `expected-error@<unknown>` in any file will now match an error diagnosed at an invalid `SourceLoc` (a.k.a `<unknown>:0`), and handling of `<unknown>:0` diagnostics has now been merged with ordinary source files instead of being done by a separate function. To implement this, I have refactored DiagnosticVerifier slightly to change the conventions around buffer IDs: * `0`, or `InvalidBufferID`, now always represents the buffer ID of an invalid source location. * `nullopt` now always represents a buffer ID that has not yet been resolved. This makes handling more consistent and allows us to specify in the type system which buffer IDs are guaranteed to be resolved. Additionally, the diagnostic verifier is now set up a little earlier so that it can capture more unknown SourceLoc diagnostics. This is probably still not early enough to capture diagnostics for syntactically invalid command line arguments, but a lot of diagnostics for problems configuring the AST context or loading implicitly-imported modules can now be verified without resorting to FileCheck. Finally, the test Interop/Cxx/Templates/function-template-typechecker-errors.swift has been reworked to use the diagnostic verifier in a more conventional fashion.
74 lines
2.9 KiB
Swift
74 lines
2.9 KiB
Swift
// RUN: %target-typecheck-verify-swift -parse-stdlib -target arm64-apple-xros2.0 %s
|
|
|
|
// expected-warning@<unknown> * {{using sysroot for }}
|
|
|
|
@available(visionOS, introduced: 1.0, deprecated: 1.5, obsoleted: 2.0,
|
|
message: "you don't want to do that anyway")
|
|
public func doSomething() { }
|
|
// expected-note @-3{{'doSomething()' was obsoleted in visionOS 2.0}}
|
|
|
|
doSomething() // expected-error{{'doSomething()' is unavailable in visionOS: you don't want to do that anyway}}
|
|
|
|
// Preservation of major.minor.micro
|
|
@available(visionOS, introduced: 1.0, deprecated: 1.5, obsoleted: 1.5.3)
|
|
func doSomethingElse() { }
|
|
// expected-note @-2{{'doSomethingElse()' was obsoleted in visionOS 1.5.3}}
|
|
|
|
doSomethingElse() // expected-error{{'doSomethingElse()' is unavailable in visionOS}}
|
|
|
|
// Preservation of minor-only version
|
|
@available(visionOS, introduced: 1.0, deprecated: 1.5, obsoleted: 2)
|
|
func doSomethingReallyOld() { }
|
|
// expected-note @-2{{'doSomethingReallyOld()' was obsoleted in visionOS 2}}
|
|
|
|
doSomethingReallyOld() // expected-error{{'doSomethingReallyOld()' is unavailable in visionOS}}
|
|
|
|
// Test deprecations in 2.0 and later
|
|
|
|
@available(visionOS, introduced: 1.1, deprecated: 2.0,
|
|
message: "Use another function")
|
|
func deprecatedFunctionWithMessage() { }
|
|
|
|
deprecatedFunctionWithMessage() // expected-warning{{'deprecatedFunctionWithMessage()' was deprecated in visionOS 2.0: Use another function}}
|
|
|
|
|
|
@available(visionOS, introduced: 1.0, deprecated: 2.0)
|
|
func deprecatedFunctionWithoutMessage() { }
|
|
|
|
deprecatedFunctionWithoutMessage() // expected-warning{{'deprecatedFunctionWithoutMessage()' was deprecated in visionOS 2.0}}
|
|
|
|
@available(visionOS, introduced: 1.0, deprecated: 2.0,
|
|
message: "Use BetterClass instead")
|
|
class DeprecatedClass { }
|
|
|
|
func functionWithDeprecatedParameter(p: DeprecatedClass) { } // expected-warning{{'DeprecatedClass' was deprecated in visionOS 2.0: Use BetterClass instead}}
|
|
|
|
@available(visionOS, introduced: 2.0, deprecated: 2.1,
|
|
message: "Use BetterClass instead")
|
|
class DeprecatedClassIn2_1 { }
|
|
|
|
// Elements deprecated later than the minimum deployment target (which is 2.0, in this case) should not generate warnings
|
|
func functionWithDeprecatedLaterParameter(p: DeprecatedClassIn2_1) { }
|
|
|
|
// Treat visionOS as an alias for iOS in availability queries
|
|
|
|
@available(visionOS, introduced: 2.2)
|
|
func functionIntroducedOnvisionOS2_2() { }
|
|
|
|
if #available(iOS 17.3, *) {
|
|
functionIntroducedOnvisionOS2_2() // expected-error{{'functionIntroducedOnvisionOS2_2()' is only available in visionOS 2.2 or newer}}
|
|
// expected-note @-1{{add 'if #available' version check}}
|
|
}
|
|
|
|
if #available(visionOS 1.5, *) {
|
|
functionIntroducedOnvisionOS2_2() // expected-error{{'functionIntroducedOnvisionOS2_2()' is only available in visionOS 2.2 or newer}}
|
|
// expected-note @-1{{add 'if #available' version check}}
|
|
}
|
|
|
|
if #available(visionOS 2.2, *) {
|
|
functionIntroducedOnvisionOS2_2()
|
|
}
|
|
|
|
@available(visionOS 1.50.4, *)
|
|
public func foo() { }
|