add --strong-null-safety flag to the kernel worker

Bug:https://github.com/dart-lang/sdk/issues/43091
Change-Id: I716d2ea6cf1c95be3911c32b1b2958788fe917ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159183
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
This commit is contained in:
Jacob MacDonald 2020-08-19 18:57:47 +00:00 committed by commit-bot@chromium.org
parent 5e551dd926
commit 1522a867ca
2 changed files with 20 additions and 6 deletions

View file

@ -25,6 +25,8 @@ import '../api_prototype/file_system.dart' show FileSystem;
import '../api_prototype/front_end.dart' show CompilerResult;
import '../base/nnbd_mode.dart' show NnbdMode;
import '../base/processed_options.dart' show ProcessedOptions;
import '../kernel_generator_impl.dart' show generateKernel;
@ -50,6 +52,8 @@ export '../api_prototype/standard_file_system.dart' show StandardFileSystem;
export '../api_prototype/terminal_color_support.dart'
show printDiagnosticMessage;
export '../base/nnbd_mode.dart' show NnbdMode;
export '../fasta/kernel/utils.dart' show serializeComponent;
export 'compiler_state.dart' show InitializedCompilerState;
@ -72,7 +76,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
bool outlineOnly,
Map<String, String> environmentDefines,
{bool trackNeededDillLibraries: false,
bool verbose: false}) async {
bool verbose: false,
NnbdMode nnbdMode: NnbdMode.Weak}) async {
List<Component> outputLoadedAdditionalDills =
new List<Component>(additionalDills.length);
Map<ExperimentalFlag, bool> experimentalFlags = parseExperimentalFlags(
@ -94,7 +99,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
omitPlatform: true,
trackNeededDillLibraries: trackNeededDillLibraries,
environmentDefines: environmentDefines,
verbose: verbose);
verbose: verbose,
nnbdMode: nnbdMode);
}
Future<InitializedCompilerState> initializeCompiler(
@ -108,6 +114,7 @@ Future<InitializedCompilerState> initializeCompiler(
Iterable<String> experiments,
Map<String, String> environmentDefines, {
bool verbose: false,
NnbdMode nnbdMode: NnbdMode.Weak,
}) async {
// TODO(sigmund): use incremental compiler when it supports our use case.
// Note: it is common for the summary worker to invoke the compiler with the
@ -125,7 +132,8 @@ Future<InitializedCompilerState> initializeCompiler(
..experimentalFlags = parseExperimentalFlags(
parseExperimentalArguments(experiments),
onError: (e) => throw e)
..verbose = verbose;
..verbose = verbose
..nnbdMode = nnbdMode;
ProcessedOptions processedOpts = new ProcessedOptions(options: options);

View file

@ -144,7 +144,8 @@ final summaryArgsParser = new ArgParser()
..addMultiOption('enable-experiment',
help: 'Enable a language experiment when invoking the CFE.')
..addMultiOption('define', abbr: 'D')
..addFlag('verbose', defaultsTo: false);
..addFlag('verbose', defaultsTo: false)
..addFlag('sound-null-safety', defaultsTo: false);
class ComputeKernelResult {
final bool succeeded;
@ -187,6 +188,9 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
var sources = (parsedArgs['source'] as List<String>).map(_toUri).toList();
var excludeNonSources = parsedArgs['exclude-non-sources'] as bool;
var nnbdMode = parsedArgs['sound-null-safety'] as bool
? fe.NnbdMode.Strong
: fe.NnbdMode.Weak;
var summaryOnly = parsedArgs['summary-only'] as bool;
var trackWidgetCreation = parsedArgs['track-widget-creation'] as bool;
@ -294,7 +298,8 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
summaryOnly,
environmentDefines,
trackNeededDillLibraries: recordUsedInputs,
verbose: verbose);
verbose: verbose,
nnbdMode: nnbdMode);
} else {
state = await fe.initializeCompiler(
// TODO(sigmund): pass an old state once we can make use of it.
@ -307,7 +312,8 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
fileSystem,
parsedArgs['enable-experiment'] as List<String>,
environmentDefines,
verbose: verbose);
verbose: verbose,
nnbdMode: nnbdMode);
}
void onDiagnostic(fe.DiagnosticMessage message) {