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:
Joe Groff
2016-02-19 13:06:26 -08:00
parent e49a50bbee
commit d4fdc1e7a8
7 changed files with 18 additions and 4 deletions

View File

@@ -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;

View File

@@ -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">;

View File

@@ -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);

View File

@@ -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,

View File

@@ -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

View File

@@ -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
}

View File

@@ -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