Files
swift-mirror/test/Parse/availability_query_custom_domains.swift
Allan Shortlidge 85444fd1e5 AST: Diagnose unrecognized platforms as errors with CustomAvailability enabled.
When the CustomAvailability experimental feature is enabled, make it an error
to specify an unrecognized availability domain name. Also, add these
diagnostics to a diagnostic group so that developers can control their behavior
when they are warnings.

Resolves rdar://152741624.
2025-06-06 17:30:01 -07:00

28 lines
1.2 KiB
Swift

// RUN: %target-typecheck-verify-swift \
// RUN: -enable-experimental-feature CustomAvailability \
// RUN: -define-enabled-availability-domain EnabledDomain \
// RUN: -define-disabled-availability-domain DisabledDomain \
// RUN: -define-dynamic-availability-domain DynamicDomain
// REQUIRES: swift_feature_CustomAvailability
if #available(EnabledDomain) { }
if #available(DisabledDomain) { }
if #available(DynamicDomain) { }
if #available(UnknownDomain) { } // expected-error {{unrecognized platform name 'UnknownDomain'}}
// expected-error@-1 {{condition required for target platform}}
if #unavailable(EnabledDomain) { }
if #unavailable(DisabledDomain) { }
if #unavailable(DynamicDomain) { }
if #unavailable(UnknownDomain) { } // expected-error {{unrecognized platform name 'UnknownDomain'}}
if #available(EnabledDomain 1.0) { } // expected-error {{unexpected version number for EnabledDomain}}
if #available(EnabledDomain, DisabledDomain) { } // expected-error {{EnabledDomain availability must be specified alone}}
if #available(EnabledDomain, swift 5) { } // expected-error {{EnabledDomain availability must be specified alone}}
while #available(EnabledDomain) { }
guard #available(EnabledDomain) else { }