Skip to content

Commit a8464dc

Browse files
committed
Implicitly import _Concurrency under -enable-experimental-concurrency
1 parent 8145566 commit a8464dc

File tree

57 files changed

+79
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+79
-13
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ class CompilerInvocation {
337337
/// Whether the Swift -Onone support library should be implicitly imported.
338338
bool shouldImportSwiftONoneSupport() const;
339339

340+
/// Whether the Swift Concurrency support library should be implicitly
341+
/// imported.
342+
bool shouldImportSwiftConcurrency() const;
343+
340344
/// Performs input setup common to these tools:
341345
/// sil-opt, sil-func-extractor, sil-llvm-gen, and sil-nm.
342346
/// Return value includes the buffer so caller can keep it alive.

include/swift/Strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ namespace swift {
2222
constexpr static const StringLiteral STDLIB_NAME = "Swift";
2323
/// The name of the Onone support library, which is a reserved module name.
2424
constexpr static const StringLiteral SWIFT_ONONE_SUPPORT = "SwiftOnoneSupport";
25+
/// The name of the Concurrency module, which supports that extension.
26+
constexpr static const StringLiteral SWIFT_CONCURRENCY_NAME = "_Concurrency";
2527
/// The name of the SwiftShims module, which contains private stdlib decls.
2628
constexpr static const StringLiteral SWIFT_SHIMS_NAME = "SwiftShims";
2729
/// The name of the Builtin module, which contains Builtin functions.

lib/Frontend/Frontend.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,10 @@ CompilerInstance::openModuleDoc(const InputFile &input) {
707707
return None;
708708
}
709709

710+
bool CompilerInvocation::shouldImportSwiftConcurrency() const {
711+
return getLangOptions().EnableExperimentalConcurrency;
712+
}
713+
710714
/// Implicitly import the SwiftOnoneSupport module in non-optimized
711715
/// builds. This allows for use of popular specialized functions
712716
/// from the standard library, which makes the non-optimized builds
@@ -758,6 +762,10 @@ ImplicitImportInfo CompilerInstance::getImplicitImportInfo() const {
758762
pushImport(SWIFT_ONONE_SUPPORT);
759763
}
760764

765+
if (Invocation.shouldImportSwiftConcurrency()) {
766+
pushImport(SWIFT_CONCURRENCY_NAME);
767+
}
768+
761769
imports.ShouldImportUnderlyingModule = frontendOpts.ImportUnderlyingModule;
762770
imports.BridgingHeaderPath = frontendOpts.ImplicitObjCHeaderPath;
763771
return imports;

test/Casting/Casts.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// RUN: %target-run %t/a.swift5.O.out
2525
//
2626
// REQUIRES: executable_test
27+
// REQUIRES: concurrency
2728
// UNSUPPORTED: use_os_stdlib
2829

2930
import StdlibUnittest

test/ClangImporter/objc_async.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -I %S/Inputs/custom-modules -enable-experimental-concurrency %s -verify
22

33
// REQUIRES: objc_interop
4+
// REQUIRES: concurrency
45
import Foundation
56
import ObjCConcurrency
67

test/Concurrency/actor_isolation.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency
22
// REQUIRES: concurrency
33

4-
import _Concurrency
5-
64
let immutableGlobal: String = "hello"
75
var mutableGlobal: String = "can't touch this" // expected-note 2{{var declared here}}
86

test/Concurrency/global_actor_inference.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency
22
// REQUIRES: concurrency
33

4-
import _Concurrency
5-
64
actor class SomeActor { }
75

86
@globalActor

test/Constraints/async.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency
22

3+
// REQUIRES: concurrency
4+
35
func doAsynchronously() async { }
46
func doSynchronously() { }
57

test/IDE/print_clang_objc_async.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %FileCheck -input-file %t/ObjCConcurrency.printed.txt %s
55

66
// REQUIRES: objc_interop
7+
// REQUIRES: concurrency
78

89
// CHECK-LABEL: class SlowServer : NSObject {
910
// CHECK-DAG: func doSomethingSlow(_ operation: String, completionHandler handler: @escaping (Int) -> Void)

test/IRGen/async.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %target-swift-frontend -primary-file %s -emit-ir -enable-experimental-concurrency | %FileCheck %s
22

3+
// REQUIRES: concurrency
4+
35
// CHECK: "$s5async1fyyYF"
46
public func f() async { }
57

0 commit comments

Comments
 (0)