Skip to content

Commit a410f5b

Browse files
sigmundchcommit-bot@chromium.org
authored andcommitted
[dart2js] rename null-safety flag and plumb through CFE
The new flag name follows the changes in dart-lang/language#779, the change also is converging on not having each tool infer a default on the input, but rely on build systems to provide the appropriate flag instead. Fixes dart-lang/sdk#39979 Change-Id: I39c143b7985dbfe6dab5dfd9a7347a7a4420479b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138569 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
1 parent 8ae984c commit a410f5b

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

pkg/compiler/lib/src/commandline_options.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class Flags {
9595

9696
static const String serverMode = '--server-mode';
9797

98-
static const String runtimeNullSafety = '--runtime-null-safety';
99-
static const String noRuntimeNullSafety = '--no-runtime-null-safety';
98+
static const String nullSafety = '--null-safety';
99+
static const String noNullSafety = '--no-null-safety';
100100

101101
static const String newDeferredSplit = '--new-deferred-split';
102102
static const String reportInvalidInferredDeferredTypes =

pkg/compiler/lib/src/dart2js.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ Future<api.CompilationResult> compile(List<String> argv,
465465
new OptionHandler(Flags.laxRuntimeTypeToString, passThrough),
466466
new OptionHandler(Flags.benchmarkingProduction, passThrough),
467467
new OptionHandler(Flags.benchmarkingExperiment, passThrough),
468-
new OptionHandler(Flags.runtimeNullSafety, setNullSafetyMode),
469-
new OptionHandler(Flags.noRuntimeNullSafety, setNullSafetyMode),
468+
new OptionHandler(Flags.nullSafety, setNullSafetyMode),
469+
new OptionHandler(Flags.noNullSafety, setNullSafetyMode),
470470

471471
// TODO(floitsch): remove conditional directives flag.
472472
// We don't provide the info-message yet, since we haven't publicly

pkg/compiler/lib/src/kernel/loader.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ class KernelLoaderTask extends CompilerTask {
105105
_options.librariesSpecificationUri,
106106
dependencies,
107107
_options.packageConfig,
108-
experimentalFlags: _options.languageExperiments);
108+
experimentalFlags: _options.languageExperiments,
109+
nnbdMode: _options.useLegacySubtyping
110+
? fe.NnbdMode.Weak
111+
: fe.NnbdMode.Strong);
109112
component = await fe.compile(
110113
initializedCompilerState,
111114
false,

pkg/compiler/lib/src/options.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,13 @@ class CompilerOptions implements DiagnosticOptions {
335335

336336
/// When null-safety is enabled, whether the compiler should emit code with
337337
/// weak or strong semantics.
338-
bool useWeakNullSafetySemantics = false;
338+
bool _useWeakNullSafetySemantics = true;
339339

340340
/// Whether to use legacy subtype semantics rather than null-safe semantics.
341341
/// This is `true` if null-safety is disabled, i.e. all code is legacy code,
342342
/// or if weak null-safety semantics are being used, since we do not emit
343343
/// warnings.
344-
bool get useLegacySubtyping => !useNullSafety || useWeakNullSafetySemantics;
344+
bool get useLegacySubtyping => !useNullSafety || _useWeakNullSafetySemantics;
345345

346346
/// The path to the file that contains the profiled allocations.
347347
///
@@ -468,11 +468,7 @@ class CompilerOptions implements DiagnosticOptions {
468468
..codegenShards = _extractIntOption(options, '${Flags.codegenShards}=')
469469
..cfeOnly = _hasOption(options, Flags.cfeOnly)
470470
..debugGlobalInference = _hasOption(options, Flags.debugGlobalInference)
471-
// TODO(sigmund): if no flag is specified, the default should depend on
472-
// whether the entry point library is opted-in (see
473-
// https://github.com/dart-lang/language/pull/779)
474-
..useWeakNullSafetySemantics =
475-
_hasOption(options, Flags.noRuntimeNullSafety);
471+
.._useWeakNullSafetySemantics = !_hasOption(options, Flags.nullSafety);
476472
}
477473

478474
void validate() {

pkg/front_end/lib/src/api_unstable/dart2js.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import '../base/processed_options.dart' show ProcessedOptions;
3333

3434
import '../base/libraries_specification.dart' show LibrariesSpecification;
3535

36+
import '../base/nnbd_mode.dart' show NnbdMode;
37+
3638
import '../fasta/compiler_context.dart' show CompilerContext;
3739

3840
import '../kernel_generator_impl.dart' show generateKernelInternal;
@@ -109,6 +111,8 @@ export '../api_prototype/kernel_generator.dart' show kernelForProgram;
109111

110112
export '../api_prototype/standard_file_system.dart' show DataFileSystemEntity;
111113

114+
export '../base/nnbd_mode.dart' show NnbdMode;
115+
112116
export '../compute_platform_binaries_location.dart'
113117
show computePlatformBinariesLocation;
114118

@@ -133,7 +137,8 @@ InitializedCompilerState initializeCompiler(
133137
Uri packagesFileUri,
134138
{List<Uri> dependencies,
135139
Map<ExperimentalFlag, bool> experimentalFlags,
136-
bool verify: false}) {
140+
bool verify: false,
141+
NnbdMode nnbdMode}) {
137142
additionalDills.sort((a, b) => a.toString().compareTo(b.toString()));
138143

139144
if (oldState != null &&
@@ -151,6 +156,7 @@ InitializedCompilerState initializeCompiler(
151156
..packagesFileUri = packagesFileUri
152157
..experimentalFlags = experimentalFlags
153158
..verify = verify;
159+
if (nnbdMode != null) options.nnbdMode = nnbdMode;
154160

155161
ProcessedOptions processedOpts = new ProcessedOptions(options: options);
156162

tools/bots/test_matrix.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@
529529
"non-nullable"
530530
],
531531
"dart2js-options": [
532-
"--no-runtime-null-safety"
532+
"--no-null-safety"
533533
],
534534
"use-sdk": true
535535
}
@@ -589,7 +589,7 @@
589589
"non-nullable"
590590
],
591591
"dart2js-options": [
592-
"--no-runtime-null-safety"
592+
"--no-null-safety"
593593
],
594594
"host-checked": true
595595
}

0 commit comments

Comments
 (0)