[AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature

(cherry picked from commit c246a7a372)
This commit is contained in:
Pavel Yaskevich
2025-05-30 00:01:58 -07:00
parent 4f88004fc0
commit d3f8fd8fd7
9 changed files with 31 additions and 5 deletions

View File

@@ -2186,6 +2186,8 @@ ERROR(nonisolated_nonsending_repeated,none,
ERROR(using_decl_invalid_specifier,PointsToFirstBadToken,
"'using' declaration does not support %0 %select{modifier|attribute}1",
(Identifier, bool))
ERROR(experimental_using_decl_disabled,PointsToFirstBadToken,
"'using' is an experimental feature that is currently disabled", ())
#define UNDEFINE_DIAGNOSTIC_MACROS
#include "DefineDiagnosticMacros.h"

View File

@@ -522,6 +522,10 @@ EXPERIMENTAL_FEATURE(AllowRuntimeSymbolDeclarations, true)
/// Optimize copies of ObjectiveC blocks.
EXPERIMENTAL_FEATURE(CopyBlockOptimization, true)
/// Allow use of `using` declaration that control default isolation
/// in a file scope.
EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
#undef EXPERIMENTAL_FEATURE
#undef UPCOMING_FEATURE

View File

@@ -632,6 +632,10 @@ static bool usesFeatureAlwaysInheritActorContext(Decl *decl) {
return false;
}
static bool usesFeatureDefaultIsolationPerFile(Decl *D) {
return isa<UsingDecl>(D);
}
// ----------------------------------------------------------------------------
// MARK: - FeatureSet
// ----------------------------------------------------------------------------

View File

@@ -78,6 +78,7 @@ extension Parser.ExperimentalFeatures {
mapFeature(.OldOwnershipOperatorSpellings, to: .oldOwnershipOperatorSpellings)
mapFeature(.KeyPathWithMethodMembers, to: .keypathWithMethodMembers)
mapFeature(.InlineArrayTypeSugar, to: .inlineArrayTypeSugar)
mapFeature(.DefaultIsolationPerFile, to: .defaultIsolationPerFile)
}
}

View File

@@ -6647,6 +6647,10 @@ ParserResult<UsingDecl> Parser::parseDeclUsing(ParseDeclOptions Flags,
assert(Tok.isContextualKeyword("using"));
DebuggerContextChange DCC(*this);
if (!Context.LangOpts.hasFeature(Feature::DefaultIsolationPerFile)) {
diagnose(Tok, diag::experimental_using_decl_disabled);
}
SourceLoc UsingLoc = consumeToken();
if (Tok.is(tok::code_complete)) {

View File

@@ -2,19 +2,22 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-concurrency -enable-experimental-feature ParserASTGen \
// RUN: -enable-experimental-feature CoroutineAccessors \
// RUN: -enable-experimental-feature DefaultIsolationPerFile \
// RUN: | %sanitize-address > %t/astgen.ast
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-concurrency \
// RUN: -enable-experimental-feature CoroutineAccessors \
// RUN: -enable-experimental-feature DefaultIsolationPerFile \
// RUN: | %sanitize-address > %t/cpp-parser.ast
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -Xfrontend -enable-experimental-concurrency -enable-experimental-feature CoroutineAccessors -enable-experimental-feature ParserASTGen)
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -Xfrontend -enable-experimental-concurrency -enable-experimental-feature CoroutineAccessors -enable-experimental-feature DefaultIsolationPerFile -enable-experimental-feature ParserASTGen)
// REQUIRES: executable_test
// REQUIRES: swift_swift_parser
// REQUIRES: swift_feature_ParserASTGen
// REQUIRES: swift_feature_CoroutineAccessors
// REQUIRES: swift_feature_DefaultIsolationPerFile
// rdar://116686158
// UNSUPPORTED: asan

View File

@@ -1,9 +1,13 @@
// RUN: %empty-directory(%t)
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-bare-slash-regex -enable-experimental-feature ParserASTGen
// RUN: %target-typecheck-verify-swift -disable-availability-checking \
// RUN: -enable-bare-slash-regex \
// RUN: -enable-experimental-feature ParserASTGen \
// RUN: -enable-experimental-feature DefaultIsolationPerFile
// REQUIRES: swift_swift_parser
// REQUIRES: swift_feature_ParserASTGen
// REQUIRES: swift_feature_DefaultIsolationPerFile
// rdar://116686158
// UNSUPPORTED: asan

View File

@@ -1,9 +1,11 @@
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -enable-experimental-feature DefaultIsolationPerFile
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface)
// RUN: %FileCheck %s --input-file %t.swiftinterface
// REQUIRES: swift_feature_DefaultIsolationPerFile
using @MainActor
// CHECK-NOT: using @MainActor

View File

@@ -1,4 +1,6 @@
// RUN: %target-typecheck-verify-swift
// RUN: %target-typecheck-verify-swift -enable-experimental-feature DefaultIsolationPerFile
// REQUIRES: swift_feature_DefaultIsolationPerFile
// REQUIRES: concurrency