Skip to content

Commit

Permalink
Make checked flag again only enable assertions in Dart 2.0
Browse files Browse the repository at this point in the history
This regressed when we swap the default to Dart 2.0 because the strongMode flag
is no longer explicit.

Fixes #33639

Change-Id: If808987efda0d11e15a9b53b81c0979c239749df
Reviewed-on: https://dart-review.googlesource.com/62442
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
  • Loading branch information
sigmundch authored and commit-bot@chromium.org committed Jun 26, 2018
1 parent e0905b9 commit 46710a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/compiler/lib/src/dart2js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ Future<api.CompilationResult> compile(List<String> argv,

if (checkedMode && strongMode) {
checkedMode = false;
hints.add("Option '${Flags.enableCheckedMode}' is not needed in Dart 2.0.");
hints.add("Option '${Flags.enableCheckedMode}' is not needed in Dart 2.0. "
"To enable assertions use '${Flags.enableAsserts}' instead.");
}

if (trustTypeAnnotations && strongMode) {
Expand Down
9 changes: 5 additions & 4 deletions pkg/compiler/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ class CompilerOptions implements DiagnosticOptions {
/// Create an options object by parsing flags from [options].
static CompilerOptions parse(List<String> options,
{Uri libraryRoot, Uri platformBinaries}) {
bool isStrong = _hasOption(options, Flags.strongMode) ||
!_hasOption(options, Flags.noPreviewDart2);
return new CompilerOptions()
..libraryRoot = libraryRoot
..allowMockCompilation = _hasOption(options, Flags.allowMockCompilation)
Expand Down Expand Up @@ -307,8 +309,8 @@ class CompilerOptions implements DiagnosticOptions {
..enableMinification = _hasOption(options, Flags.minify)
..enableNativeLiveTypeAnalysis =
!_hasOption(options, Flags.disableNativeLiveTypeAnalysis)
..enableTypeAssertions = _hasOption(options, Flags.enableCheckedMode) &&
!_hasOption(options, Flags.strongMode)
..enableTypeAssertions =
_hasOption(options, Flags.enableCheckedMode) && !isStrong
..enableUserAssertions = _hasOption(options, Flags.enableCheckedMode) ||
_hasOption(options, Flags.enableAsserts)
..experimentalTrackAllocations =
Expand All @@ -325,8 +327,7 @@ class CompilerOptions implements DiagnosticOptions {
..platformBinaries =
platformBinaries ?? _extractUriOption(options, '--platform-binaries=')
..sourceMapUri = _extractUriOption(options, '--source-map=')
..strongMode = _hasOption(options, Flags.strongMode) ||
!_hasOption(options, Flags.noPreviewDart2)
..strongMode = isStrong
..omitImplicitChecks = _hasOption(options, Flags.omitImplicitChecks)
..laxRuntimeTypeToString =
_hasOption(options, Flags.laxRuntimeTypeToString)
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/dart2js/rti/bound_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ main(List<String> args) {
], expectedOutput: OUTPUT1, printJs: args.contains('-v'));
await runWithD8(
memorySourceFiles: {'main.dart': SOURCE2},
options: [Flags.enableCheckedMode],
options: [Flags.noPreviewDart2, Flags.enableCheckedMode],
expectedOutput: OUTPUT2,
printJs: args.contains('-v'));
});
Expand Down

0 comments on commit 46710a7

Please sign in to comment.