mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Conditionally enable behaviors by a frontend flag.
Since the feature is incomplete and yet to be accepted or implemented as proposed, hide it behind an -enable-experimental-property-behaviors frontend flag.
This commit is contained in:
@@ -137,6 +137,9 @@ namespace swift {
|
||||
/// \brief Enable experimental "switch" pattern-matching features.
|
||||
bool EnableExperimentalPatterns = false;
|
||||
|
||||
/// \brief Enable experimental property behavior feature.
|
||||
bool EnableExperimentalPropertyBehaviors = false;
|
||||
|
||||
/// Should we check the target OSs of serialized modules to see that they're
|
||||
/// new enough?
|
||||
bool EnableTargetOSChecking = true;
|
||||
|
||||
@@ -216,6 +216,10 @@ def emit_verbose_sil : Flag<["-"], "emit-verbose-sil">,
|
||||
def enable_experimental_patterns : Flag<["-"], "enable-experimental-patterns">,
|
||||
HelpText<"Enable experimental 'switch' pattern matching features">;
|
||||
|
||||
def enable_experimental_property_behaviors :
|
||||
Flag<["-"], "enable-experimental-property-behaviors">,
|
||||
HelpText<"Enable experimental property behaviors">;
|
||||
|
||||
def disable_availability_checking : Flag<["-"],
|
||||
"disable-availability-checking">,
|
||||
HelpText<"Disable checking for potentially unavailable APIs">;
|
||||
|
||||
@@ -726,6 +726,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
Opts.EnableExperimentalPatterns |=
|
||||
Args.hasArg(OPT_enable_experimental_patterns);
|
||||
|
||||
Opts.EnableExperimentalPropertyBehaviors |=
|
||||
Args.hasArg(OPT_enable_experimental_property_behaviors);
|
||||
|
||||
Opts.DisableAvailabilityChecking |=
|
||||
Args.hasArg(OPT_disable_availability_checking);
|
||||
|
||||
|
||||
@@ -3830,7 +3830,8 @@ ParserStatus Parser::parseDeclVar(ParseDeclOptions Flags,
|
||||
};
|
||||
|
||||
// Check for a behavior declaration.
|
||||
if (Tok.is(tok::l_square)) {
|
||||
if (Context.LangOpts.EnableExperimentalPropertyBehaviors
|
||||
&& Tok.is(tok::l_square)) {
|
||||
BehaviorLBracket = consumeToken(tok::l_square);
|
||||
// TODO: parse visibility (public/private/internal)
|
||||
auto type = parseType(diag::expected_behavior_name,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// RUN: %target-run-simple-swift
|
||||
// RUN: rm -rf %t
|
||||
// RUN: mkdir -p %t
|
||||
// RUN: %target-build-swift -Xfrontend -enable-experimental-property-behaviors %s -o %t/a.out
|
||||
// RUN: %target-run %t/a.out
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-silgen -enable-experimental-property-behaviors %s | FileCheck %s
|
||||
protocol behavior {
|
||||
associatedtype Value
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-parse-verify-swift -module-name Main
|
||||
// RUN: %target-parse-verify-swift -enable-experimental-property-behaviors -module-name Main
|
||||
|
||||
protocol behavior {
|
||||
associatedtype Value
|
||||
|
||||
Reference in New Issue
Block a user