ModuleInterface: Guard declarations that use the $CustomAvailability feature.

This commit is contained in:
Allan Shortlidge
2025-04-07 16:07:27 -07:00
parent 1cd636d9b3
commit 38e56fcec0
4 changed files with 37 additions and 11 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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;
}

View 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() { }