Files
swift-mirror/test/Parse/diagnose_availability_windows.swift
Allan Shortlidge 592b70f00f AST: Fix AvailabilityContext platform range for certain targets.
https://github.com/swiftlang/swift/pull/79807 caused a regression in which
`AvailabilityContext` stopped tracking the available version range for the
active platform domain for certain platforms. Fix this by reverting to checking
`AvailabilityDomain::isActive()` to determine when a given platform
`AvailabilityDomain` represents the target platform. The compiler's existing
mapping from target triple to platform domain is incomplete and it's not clear
to me whether fixing that could cause other regressions.

Resolves rdar://147413616.
2025-03-20 16:26:54 -07:00

45 lines
1.5 KiB
Swift

// RUN: %target-typecheck-verify-swift -target x86_64-unknown-windows-msvc -parse-stdlib -verify-additional-prefix no-target-
// RUN: %target-typecheck-verify-swift -target x86_64-unknown-windows8.0-msvc -parse-stdlib
// expected-note@+2{{'unavailable()' has been explicitly marked unavailable here}}
@available(Windows, unavailable, message: "unsupported")
func unavailable() {}
// expected-error@+1 {{'unavailable()' is unavailable in Windows: unsupported}}
unavailable()
@available(Windows, introduced: 10.0.17763, deprecated: 10.0.19140)
func introduced_deprecated() {}
// expected-error@+1 {{'introduced_deprecated()' is only available in Windows 10.0.17763 or newer}}
introduced_deprecated()
// expected-note@-1 {{add 'if #available' version check}}
@available(Windows 8, *)
func windows8() {}
@available(Windows 10, *)
func windows10() {}
windows8() // expected-no-target-error {{'windows8()' is only available in Windows 8 or newer}}
// expected-no-target-note@-1 {{add 'if #available' version check}}
// expected-error@+1 {{'windows10()' is only available in Windows 10 or newer}}
windows10()
// expected-note@-1 {{add 'if #available' version check}}
func conditional_compilation() {
// expected-note@-1 {{add @available attribute to enclosing global function}}
if #available(Windows 10, *) {
windows10() // OK
} else {
windows10() // expected-error {{'windows10()' is only available in Windows 10 or newer}}
// expected-note@-1 {{add 'if #available' version check}}
}
}
@available(Windows 10, *)
func windows10_caller() {
windows10() // OK
}