@@ -154,9 +154,12 @@ ArgParser argParser = ArgParser(allowTrailingOptions: true)
154154 help: 'Include only bytecode into the output file' , defaultsTo: true )
155155 ..addFlag ('enable-asserts' ,
156156 help: 'Whether asserts will be enabled.' , defaultsTo: false )
157+ ..addFlag ('sound-null-safety' ,
158+ help: 'Respect the nullability of types at runtime.' , defaultsTo: null )
159+ // TODO(alexmarkov) Remove obsolete --null-safety option.
157160 ..addFlag ('null-safety' ,
158- help:
159- 'Respect the nullability of types at runtime in casts and instance checks.' ,
161+ help: 'Deprecated. Please use --sound-null-safety instead.' ,
162+ hide : true ,
160163 defaultsTo: null )
161164 ..addMultiOption ('enable-experiment' ,
162165 help: 'Comma separated list of experimental features, eg set-literals.' ,
@@ -407,6 +410,8 @@ class FrontendCompiler implements CompilerInterface {
407410 final String platformKernelDill =
408411 options['platform' ] ?? 'platform_strong.dill' ;
409412 final String packagesOption = _options['packages' ];
413+ final bool nullSafety =
414+ _options['sound-null-safety' ] ?? _options['null-safety' ];
410415 final CompilerOptions compilerOptions = CompilerOptions ()
411416 ..sdkRoot = sdkRoot
412417 ..fileSystem = _fileSystem
@@ -418,8 +423,7 @@ class FrontendCompiler implements CompilerInterface {
418423 ..experimentalFlags = parseExperimentalFlags (
419424 parseExperimentalArguments (options['enable-experiment' ]),
420425 onError: (msg) => errors.add (msg))
421- ..nnbdMode =
422- (options['null-safety' ] == true ) ? NnbdMode .Strong : NnbdMode .Weak
426+ ..nnbdMode = (nullSafety == true ) ? NnbdMode .Strong : NnbdMode .Weak
423427 ..onDiagnostic = _onDiagnostic;
424428
425429 if (options.wasParsed ('libraries-spec' )) {
@@ -469,7 +473,7 @@ class FrontendCompiler implements CompilerInterface {
469473 }
470474 }
471475
472- if (options[ 'null-safety' ] == null &&
476+ if (nullSafety == null &&
473477 compilerOptions.experimentalFlags[ExperimentalFlag .nonNullable]) {
474478 await autoDetectNullSafetyMode (_mainSource, compilerOptions);
475479 }
0 commit comments