Skip to content

Commit 7f5e1d1

Browse files
committed
[AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature
1 parent be97e2d commit 7f5e1d1

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8783,6 +8783,8 @@ ERROR(invalid_redecl_of_file_isolation,none,
87838783
"invalid redeclaration of file-level default actor isolation", ())
87848784
NOTE(invalid_redecl_of_file_isolation_prev,none,
87858785
"default isolation was previously declared here", ())
8786+
ERROR(experimental_using_decl,none,
8787+
"'using' declarations are experimental", ())
87868788

87878789
#define UNDEFINE_DIAGNOSTIC_MACROS
87888790
#include "DefineDiagnosticMacros.h"

include/swift/Basic/Features.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExtensibleAttribute, false)
521521
/// Allow use of `Module::name` syntax
522522
EXPERIMENTAL_FEATURE(ModuleSelector, false)
523523

524+
/// Allow use of `using` declaration that control default isolation
525+
/// in a file scope.
526+
EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
527+
524528
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
525529
#undef EXPERIMENTAL_FEATURE
526530
#undef UPCOMING_FEATURE

lib/AST/FeatureSet.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ static bool usesFeatureAlwaysInheritActorContext(Decl *decl) {
643643
return false;
644644
}
645645

646+
static bool usesFeatureDefaultIsolationPerFile(Decl *D) {
647+
return isa<UsingDecl>(D);
648+
}
649+
646650
UNINTERESTING_FEATURE(BuiltinSelect)
647651

648652
// ----------------------------------------------------------------------------

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,12 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
25072507
}
25082508

25092509
void visitUsingDecl(UsingDecl *UD) {
2510-
// Nothing to validate yet.
2510+
auto &ctx = UD->getASTContext();
2511+
2512+
if (!ctx.LangOpts.hasFeature(Feature::DefaultIsolationPerFile))
2513+
UD->diagnose(diag::experimental_using_decl);
2514+
2515+
TypeChecker::checkDeclAttributes(UD);
25112516
}
25122517

25132518
void visitOperatorDecl(OperatorDecl *OD) {

test/ModuleInterface/using.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s
1+
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -enable-experimental-feature DefaultIsolationPerFile
22

33
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface)
44

55
// RUN: %FileCheck %s --input-file %t.swiftinterface
66

7+
// REQUIRES: swift_feature_DefaultIsolationPerFile
8+
79
using @MainActor
810

911
// CHECK-NOT: using @MainActor

test/Parse/using.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-feature DefaultIsolationPerFile
2+
3+
// REQUIRES: swift_feature_DefaultIsolationPerFile
24

35
using @MainActor
46
using nonisolated

0 commit comments

Comments
 (0)