Skip to content

Commit 10c910e

Browse files
committed
ModuleInterface: Guard declarations that use the $CustomAvailability feature.
1 parent abac42b commit 10c910e

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

include/swift/Basic/Features.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExecutionAttribute, false)
493493
ADOPTABLE_EXPERIMENTAL_FEATURE(AsyncCallerExecution, false)
494494

495495
/// Allow custom availability domains to be defined and referenced.
496-
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CustomAvailability, true)
496+
EXPERIMENTAL_FEATURE(CustomAvailability, true)
497497

498498
/// Allow isolated conformances.
499499
EXPERIMENTAL_FEATURE(IsolatedConformances, true)

lib/AST/ASTPrinter.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -3302,14 +3302,6 @@ suppressingFeatureAddressableTypes(PrintOptions &options,
33023302
action();
33033303
}
33043304

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

lib/AST/FeatureSet.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,10 @@ static bool usesFeatureCoroutineAccessors(Decl *decl) {
490490
}
491491

492492
static bool usesFeatureCustomAvailability(Decl *decl) {
493-
// FIXME: [availability] Check whether @available attributes for custom
494-
// domains are attached to the decl.
493+
for (auto attr : decl->getSemanticAvailableAttrs()) {
494+
if (attr.getDomain().isCustom())
495+
return true;
496+
}
495497
return false;
496498
}
497499

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)