mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add a flag to enable ConcurrentValue inference for public structs/enums.
This commit is contained in:
@@ -247,6 +247,9 @@ namespace swift {
|
||||
/// Enable experimental flow-sensitive concurrent captures.
|
||||
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
|
||||
|
||||
/// Enable inference of ConcurrentValue conformances for public types.
|
||||
bool EnableInferPublicConcurrentValue = false;
|
||||
|
||||
/// Enable experimental derivation of `Codable` for enums.
|
||||
bool EnableExperimentalEnumCodableDerivation = false;
|
||||
|
||||
|
||||
@@ -188,6 +188,12 @@ def batch_scan_input_file
|
||||
def import_prescan : Flag<["-"], "import-prescan">,
|
||||
HelpText<"When performing a dependency scan, only dentify all imports of the main Swift module sources">;
|
||||
|
||||
def enable_infer_public_concurrent_value : Flag<["-"], "enable-infer-public-concurrent-value">,
|
||||
HelpText<"Enable inference of ConcurrentValue conformances for public structs and enums">;
|
||||
|
||||
def disable_infer_public_concurrent_value : Flag<["-"], "disable-infer-public-concurrent-value">,
|
||||
HelpText<"Disable inference of ConcurrentValue conformances for public structs and enums">;
|
||||
|
||||
} // end let Flags = [FrontendOption, NoDriverOption]
|
||||
|
||||
def debug_crash_Group : OptionGroup<"<automatic crashing options>">;
|
||||
|
||||
@@ -385,6 +385,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
|
||||
Opts.EnableExperimentalConcurrency |=
|
||||
Args.hasArg(OPT_enable_experimental_concurrency);
|
||||
Opts.EnableInferPublicConcurrentValue |=
|
||||
Args.hasFlag(OPT_enable_infer_public_concurrent_value,
|
||||
OPT_disable_infer_public_concurrent_value,
|
||||
false);
|
||||
Opts.EnableExperimentalFlowSensitiveConcurrentCaptures |=
|
||||
Args.hasArg(OPT_enable_experimental_flow_sensitive_concurrent_captures);
|
||||
|
||||
|
||||
@@ -2510,7 +2510,8 @@ NormalProtocolConformance *GetImplicitConcurrentValueRequest::evaluate(
|
||||
|
||||
// Public, non-frozen structs and enums defined in Swift don't get implicit
|
||||
// ConcurrentValue conformances.
|
||||
if (nominal->getFormalAccessScope(
|
||||
if (!nominal->getASTContext().LangOpts.EnableInferPublicConcurrentValue &&
|
||||
nominal->getFormalAccessScope(
|
||||
/*useDC=*/nullptr,
|
||||
/*treatUsableFromInlineAsPublic=*/true).isPublic() &&
|
||||
!(nominal->hasClangNode() ||
|
||||
|
||||
16
test/Concurrency/concurrent_value_inference_public.swift
Normal file
16
test/Concurrency/concurrent_value_inference_public.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
// RUN: %target-typecheck-verify-swift -enable-infer-public-concurrent-value
|
||||
|
||||
func acceptCV<T: ConcurrentValue>(_: T) { }
|
||||
|
||||
public struct PublicStruct {
|
||||
var i: Int
|
||||
}
|
||||
|
||||
public enum PublicEnum {
|
||||
case some
|
||||
}
|
||||
|
||||
func testCV(ps: PublicStruct, pe: PublicEnum) {
|
||||
acceptCV(ps)
|
||||
acceptCV(pe)
|
||||
}
|
||||
Reference in New Issue
Block a user