mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Diagnose availability of availability domains in if #available queries.
When emitting statement diagnostics for `if #available` queries, diagnose the availability of the decls representing the referenced availability domains. Among other things, this checks that the domains are sufficiently visible to be used in the containing function body context.
This commit is contained in:
30
test/ClangImporter/availability_custom_domains_access.swift
Normal file
30
test/ClangImporter/availability_custom_domains_access.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify \
|
||||
// RUN: -import-objc-header %S/Inputs/availability_domains_bridging_header.h \
|
||||
// RUN: -I %S/../Inputs/custom-modules/availability-domains \
|
||||
// RUN: -enable-experimental-feature CustomAvailability \
|
||||
// RUN: %s
|
||||
|
||||
// REQUIRES: swift_feature_CustomAvailability
|
||||
|
||||
private import Rivers // also re-exported by Oceans
|
||||
internal import Oceans
|
||||
// expected-note@-1 {{availability domain 'Arctic' imported as 'internal' from 'Oceans' here}}
|
||||
// expected-note@-2 {{availability domain 'Colorado' imported as 'internal' from 'Oceans' here}}
|
||||
// expected-note@-3 {{availability domain 'Grand' imported as 'internal' from 'Oceans' here}}
|
||||
public import Seas
|
||||
|
||||
@inlinable public func inlinableFunc() {
|
||||
if #available(Colorado) { } // expected-error {{availability domain 'Colorado' is internal and cannot be referenced from an '@inlinable' function}}
|
||||
if #available(Grand) { } // expected-error {{availability domain 'Grand' is internal and cannot be referenced from an '@inlinable' function}}
|
||||
if #available(Arctic) { } // expected-error {{availability domain 'Arctic' is internal and cannot be referenced from an '@inlinable' function}}
|
||||
if #available(Baltic) { }
|
||||
if #available(BayBridge) { }
|
||||
}
|
||||
|
||||
public func nonInlinablePublicFunc() {
|
||||
if #available(Colorado) { }
|
||||
if #available(Grand) { } // expected-warning {{availability domain 'Grand' is deprecated: Use Colorado instead}}
|
||||
if #available(Arctic) { }
|
||||
if #available(Baltic) { }
|
||||
if #available(BayBridge) { }
|
||||
}
|
||||
Reference in New Issue
Block a user