Merge pull request #81863 from xedin/using-for-default-isolation-in-file-context

[AST/Sema] SE-0478:  Implement `using` declaration under an experimental flag
This commit is contained in:
Pavel Yaskevich
2025-06-02 09:56:29 -07:00
committed by GitHub
57 changed files with 590 additions and 9 deletions

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
@@ -31,6 +34,10 @@ import protocol Swift.Sequence
import func Swift.max
import var Swift._playgroundPrintHook
using @MainActor
// FIXME: cannot add `using nonisolated` here because it's a re-declaration
func
test1
(

View File

@@ -1,9 +1,14 @@
// 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
@@ -66,3 +71,12 @@ func misisngPatternTest(arr: [Int]) {
for {} // expected-error {{expected pattern, 'in', and expression in 'for' statement}}
// expected-note@-1 {{insert pattern, 'in', and expression}} {{7-7=<#pattern#> }} {{7-7=in }} {{7-7=<#expression#> }}
}
using @MainActor // expected-note {{default isolation was previously declared here}}
using nonisolated // expected-error {{invalid redeclaration of file-level default actor isolation}}
using @Test
// expected-error@-1 {{default isolation can only be set to '@MainActor' or 'nonisolated'}}
using test
// expected-error@-1 {{default isolation can only be set to '@MainActor' or 'nonisolated'}}