Skip to content

Commit b8fb94b

Browse files
committed
[Frontend] NFC: Add a flag to enable bridging of completion handlers to checked continuations
1 parent a602531 commit b8fb94b

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ namespace swift {
389389
bool DisableImplicitBacktracingModuleImport =
390390
!SWIFT_IMPLICIT_BACKTRACING_IMPORT;
391391

392+
// Whether to use checked continuations when making an async call from
393+
// Swift into ObjC. If false, will use unchecked continuations instead.
394+
bool UseCheckedAsyncObjCBridging = false;
395+
392396
/// Should we check the target OSs of serialized modules to see that they're
393397
/// new enough?
394398
bool EnableTargetOSChecking = true;

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ def enable_experimental_async_top_level :
361361
// HIDDEN FLAGS
362362
let Flags = [FrontendOption, NoDriverOption, HelpHidden] in {
363363

364+
def checked_async_objc_bridging : Joined<["-"], "checked-async-objc-bridging=">,
365+
HelpText<"Control whether checked continuations are used when bridging "
366+
"async calls from Swift to ObjC: 'on', 'off' ">;
367+
364368
def debug_constraints : Flag<["-"], "debug-constraints">,
365369
HelpText<"Debug the constraint-based type checker">;
366370

lib/Frontend/CompilerInvocation.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,21 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
13211321
HadError = true;
13221322
}
13231323

1324+
if (auto A = Args.getLastArg(OPT_checked_async_objc_bridging)) {
1325+
auto value = llvm::StringSwitch<llvm::Optional<bool>>(A->getValue())
1326+
.Case("off", false)
1327+
.Case("on", true)
1328+
.Default(llvm::None);
1329+
1330+
if (value) {
1331+
Opts.UseCheckedAsyncObjCBridging = *value;
1332+
} else {
1333+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
1334+
A->getAsString(Args), A->getValue());
1335+
HadError = true;
1336+
}
1337+
}
1338+
13241339
return HadError || UnsupportedOS || UnsupportedArch;
13251340
}
13261341

test/SILGen/objc_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -I %S/Inputs/custom-modules -disable-availability-checking %s -verify | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -checked-async-objc-bridging=off -I %S/Inputs/custom-modules -disable-availability-checking %s -verify | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
22
// REQUIRES: concurrency
33
// REQUIRES: objc_interop
44

test/SILGen/objc_effectful_properties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -disable-availability-checking -I %S/Inputs/custom-modules %s -verify | %FileCheck --enable-var-scope --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -checked-async-objc-bridging=off -disable-availability-checking -I %S/Inputs/custom-modules %s -verify | %FileCheck --enable-var-scope --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
22
// REQUIRES: concurrency
33
// REQUIRES: objc_interop
44

0 commit comments

Comments
 (0)