Skip to content

Commit f82e962

Browse files
authored
Merge pull request #34609 from apple/disable-implicit-concur-import
2 parents 80c4c90 + 72d3d30 commit f82e962

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ namespace swift {
245245
/// Enable experimental concurrency model.
246246
bool EnableExperimentalConcurrency = false;
247247

248+
/// Disable the implicit import of the _Concurrency module.
249+
bool DisableImplicitConcurrencyModuleImport = false;
250+
248251
/// Should we check the target OSs of serialized modules to see that they're
249252
/// new enough?
250253
bool EnableTargetOSChecking = true;

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ def disable_clangimporter_source_import : Flag<["-"],
286286
"disable-clangimporter-source-import">,
287287
HelpText<"Disable ClangImporter and forward all requests straight the DWARF importer.">;
288288

289+
def disable_implicit_concurrency_module_import : Flag<["-"],
290+
"disable-implicit-concurrency-module-import">,
291+
HelpText<"Disable the implicit import of the _Concurrency module.">;
292+
289293
def disable_arc_opts : Flag<["-"], "disable-arc-opts">,
290294
HelpText<"Don't run SIL ARC optimization passes.">;
291295
def disable_ossa_opts : Flag<["-"], "disable-ossa-opts">,

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
376376
Opts.EnableExperimentalConcurrency |=
377377
Args.hasArg(OPT_enable_experimental_concurrency);
378378

379+
Opts.DisableImplicitConcurrencyModuleImport |=
380+
Args.hasArg(OPT_disable_implicit_concurrency_module_import);
381+
379382
Opts.EnableSubstSILFunctionTypesForFunctionValues |=
380383
Args.hasArg(OPT_enable_subst_sil_function_types_for_function_values);
381384

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,8 @@ CompilerInstance::openModuleDoc(const InputFile &input) {
708708
}
709709

710710
bool CompilerInvocation::shouldImportSwiftConcurrency() const {
711-
return getLangOptions().EnableExperimentalConcurrency;
711+
return getLangOptions().EnableExperimentalConcurrency
712+
&& !getLangOptions().DisableImplicitConcurrencyModuleImport;
712713
}
713714

714715
/// Implicitly import the SwiftOnoneSupport module in non-optimized

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,12 @@ function(add_swift_target_library name)
16571657
list(APPEND SWIFTLIB_DEPENDS clang)
16581658
endif()
16591659

1660+
# Turn off implicit import of _Concurrency when building libraries
1661+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
1662+
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS
1663+
"-Xfrontend;-disable-implicit-concurrency-module-import")
1664+
endif()
1665+
16601666
# If we are building this library for targets, loop through the various
16611667
# SDKs building the variants of this library.
16621668
list_intersect(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -disable-implicit-concurrency-module-import
2+
// REQUIRES: concurrency
3+
4+
5+
protocol P : Actor { } // expected-error{{cannot find type 'Actor' in scope}}

0 commit comments

Comments
 (0)