Skip to content

Commit a587891

Browse files
committed
ModuleInterface: Guard declarations that use the $CustomAvailability feature.
1 parent f1c26bc commit a587891

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExecutionAttribute, false)
490490
ADOPTABLE_EXPERIMENTAL_FEATURE(AsyncCallerExecution, false)
491491

492492
/// Allow custom availability domains to be defined and referenced.
493-
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CustomAvailability, true)
493+
EXPERIMENTAL_FEATURE(CustomAvailability, true)
494494

495495
/// Allow public enumerations to be extensible by default
496496
/// regardless of whether the module they are declared in

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,14 +3301,6 @@ suppressingFeatureAddressableTypes(PrintOptions &options,
33013301
action();
33023302
}
33033303

3304-
static void
3305-
suppressingFeatureCustomAvailability(PrintOptions &options,
3306-
llvm::function_ref<void()> action) {
3307-
// FIXME: [availability] Save and restore a bit controlling whether
3308-
// @available attributes for custom domains are printed.
3309-
action();
3310-
}
3311-
33123304
static void
33133305
suppressingFeatureExecutionAttribute(PrintOptions &options,
33143306
llvm::function_ref<void()> action) {

lib/AST/FeatureSet.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,10 @@ static bool usesFeatureCoroutineAccessors(Decl *decl) {
468468
}
469469

470470
static bool usesFeatureCustomAvailability(Decl *decl) {
471-
// FIXME: [availability] Check whether @available attributes for custom
472-
// domains are attached to the decl.
471+
for (auto attr : decl->getSemanticAvailableAttrs()) {
472+
if (attr.getDomain().isCustom())
473+
return true;
474+
}
473475
return false;
474476
}
475477

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-emit-module-interface(%t/Test.swiftinterface) %s \
4+
// RUN: -I %S/../Inputs/custom-modules/availability-domains \
5+
// RUN: -enable-experimental-feature CustomAvailability \
6+
// RUN: -module-name Test
7+
8+
// RUN: %target-swift-typecheck-module-from-interface(%t/Test.swiftinterface) \
9+
// RUN: -I %S/../Inputs/custom-modules/availability-domains \
10+
// RUN: -module-name Test
11+
12+
// RUN: %FileCheck %s < %t/Test.swiftinterface
13+
14+
// REQUIRES: swift_feature_CustomAvailability
15+
16+
import Oceans // re-exports Rivers
17+
18+
// CHECK: #if compiler(>=5.3) && $CustomAvailability
19+
// CHECK-NEXT: @available(Colorado)
20+
// CHECK-NEXT: public func availableInColorado()
21+
// CHECK-NEXT: #endif
22+
@available(Colorado)
23+
public func availableInColorado() { }
24+
25+
// CHECK: #if compiler(>=5.3) && $CustomAvailability
26+
// CHECK-NEXT: @available(Arctic, unavailable)
27+
// CHECK-NEXT: @available(Pacific)
28+
// CHECK-NEXT: public func unavailableInArcticButAvailableInPacific()
29+
// CHECK-NEXT: #endif
30+
@available(Arctic, unavailable)
31+
@available(Pacific)
32+
public func unavailableInArcticButAvailableInPacific() { }

0 commit comments

Comments
 (0)