mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
37 lines
1.1 KiB
Swift
37 lines
1.1 KiB
Swift
// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.9 -typecheck -verify %s
|
|
// REQUIRES: OS=macosx
|
|
|
|
struct Butt {
|
|
var setter_conditionally_available: Int {
|
|
get { fatalError() }
|
|
|
|
@available(macOS 10.10, *)
|
|
set { fatalError() }
|
|
}
|
|
}
|
|
|
|
func assertExactType<T>(of _: inout T, is _: T.Type) {}
|
|
|
|
@available(macOS 10.9, *)
|
|
public func unavailableSetterContext() {
|
|
var kp = \Butt.setter_conditionally_available
|
|
assertExactType(of: &kp, is: KeyPath<Butt, Int>.self)
|
|
}
|
|
@available(macOS 10.10, *)
|
|
public func availableSetterContext() {
|
|
var kp = \Butt.setter_conditionally_available
|
|
assertExactType(of: &kp, is: WritableKeyPath<Butt, Int>.self)
|
|
}
|
|
@available(macOS 10.9, *)
|
|
public func conditionalAvailableSetterContext() {
|
|
if #available(macOS 10.10, *) {
|
|
var kp = \Butt.setter_conditionally_available
|
|
assertExactType(of: &kp, is: WritableKeyPath<Butt, Int>.self)
|
|
} else {
|
|
var kp = \Butt.setter_conditionally_available
|
|
assertExactType(of: &kp, is: KeyPath<Butt, Int>.self)
|
|
}
|
|
}
|
|
|
|
// FIXME: Check additional unavailability conditions
|