mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ModuleInterface: Guard declarations that use the $CustomAvailability feature.
This commit is contained in:
@@ -490,7 +490,7 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExecutionAttribute, false)
|
||||
ADOPTABLE_EXPERIMENTAL_FEATURE(AsyncCallerExecution, false)
|
||||
|
||||
/// Allow custom availability domains to be defined and referenced.
|
||||
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CustomAvailability, true)
|
||||
EXPERIMENTAL_FEATURE(CustomAvailability, true)
|
||||
|
||||
/// Allow public enumerations to be extensible by default
|
||||
/// regardless of whether the module they are declared in
|
||||
|
||||
@@ -3301,14 +3301,6 @@ suppressingFeatureAddressableTypes(PrintOptions &options,
|
||||
action();
|
||||
}
|
||||
|
||||
static void
|
||||
suppressingFeatureCustomAvailability(PrintOptions &options,
|
||||
llvm::function_ref<void()> action) {
|
||||
// FIXME: [availability] Save and restore a bit controlling whether
|
||||
// @available attributes for custom domains are printed.
|
||||
action();
|
||||
}
|
||||
|
||||
static void
|
||||
suppressingFeatureExecutionAttribute(PrintOptions &options,
|
||||
llvm::function_ref<void()> action) {
|
||||
|
||||
@@ -468,8 +468,10 @@ static bool usesFeatureCoroutineAccessors(Decl *decl) {
|
||||
}
|
||||
|
||||
static bool usesFeatureCustomAvailability(Decl *decl) {
|
||||
// FIXME: [availability] Check whether @available attributes for custom
|
||||
// domains are attached to the decl.
|
||||
for (auto attr : decl->getSemanticAvailableAttrs()) {
|
||||
if (attr.getDomain().isCustom())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
32
test/ModuleInterface/availability_custom_domains.swift
Normal file
32
test/ModuleInterface/availability_custom_domains.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// RUN: %target-swift-emit-module-interface(%t/Test.swiftinterface) %s \
|
||||
// RUN: -I %S/../Inputs/custom-modules/availability-domains \
|
||||
// RUN: -enable-experimental-feature CustomAvailability \
|
||||
// RUN: -module-name Test
|
||||
|
||||
// RUN: %target-swift-typecheck-module-from-interface(%t/Test.swiftinterface) \
|
||||
// RUN: -I %S/../Inputs/custom-modules/availability-domains \
|
||||
// RUN: -module-name Test
|
||||
|
||||
// RUN: %FileCheck %s < %t/Test.swiftinterface
|
||||
|
||||
// REQUIRES: swift_feature_CustomAvailability
|
||||
|
||||
import Oceans // re-exports Rivers
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $CustomAvailability
|
||||
// CHECK-NEXT: @available(Colorado)
|
||||
// CHECK-NEXT: public func availableInColorado()
|
||||
// CHECK-NEXT: #endif
|
||||
@available(Colorado)
|
||||
public func availableInColorado() { }
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $CustomAvailability
|
||||
// CHECK-NEXT: @available(Arctic, unavailable)
|
||||
// CHECK-NEXT: @available(Pacific)
|
||||
// CHECK-NEXT: public func unavailableInArcticButAvailableInPacific()
|
||||
// CHECK-NEXT: #endif
|
||||
@available(Arctic, unavailable)
|
||||
@available(Pacific)
|
||||
public func unavailableInArcticButAvailableInPacific() { }
|
||||
Reference in New Issue
Block a user