Skip to content

Commit 1522a86

Browse files
jakemac53commit-bot@chromium.org
authored andcommitted
add --strong-null-safety flag to the kernel worker
Bug:#43091 Change-Id: I716d2ea6cf1c95be3911c32b1b2958788fe917ef Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159183 Reviewed-by: Jens Johansen <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Jake Macdonald <[email protected]>
1 parent 5e551dd commit 1522a86

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import '../api_prototype/file_system.dart' show FileSystem;
2525

2626
import '../api_prototype/front_end.dart' show CompilerResult;
2727

28+
import '../base/nnbd_mode.dart' show NnbdMode;
29+
2830
import '../base/processed_options.dart' show ProcessedOptions;
2931

3032
import '../kernel_generator_impl.dart' show generateKernel;
@@ -50,6 +52,8 @@ export '../api_prototype/standard_file_system.dart' show StandardFileSystem;
5052
export '../api_prototype/terminal_color_support.dart'
5153
show printDiagnosticMessage;
5254

55+
export '../base/nnbd_mode.dart' show NnbdMode;
56+
5357
export '../fasta/kernel/utils.dart' show serializeComponent;
5458

5559
export 'compiler_state.dart' show InitializedCompilerState;
@@ -72,7 +76,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
7276
bool outlineOnly,
7377
Map<String, String> environmentDefines,
7478
{bool trackNeededDillLibraries: false,
75-
bool verbose: false}) async {
79+
bool verbose: false,
80+
NnbdMode nnbdMode: NnbdMode.Weak}) async {
7681
List<Component> outputLoadedAdditionalDills =
7782
new List<Component>(additionalDills.length);
7883
Map<ExperimentalFlag, bool> experimentalFlags = parseExperimentalFlags(
@@ -94,7 +99,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
9499
omitPlatform: true,
95100
trackNeededDillLibraries: trackNeededDillLibraries,
96101
environmentDefines: environmentDefines,
97-
verbose: verbose);
102+
verbose: verbose,
103+
nnbdMode: nnbdMode);
98104
}
99105

100106
Future<InitializedCompilerState> initializeCompiler(
@@ -108,6 +114,7 @@ Future<InitializedCompilerState> initializeCompiler(
108114
Iterable<String> experiments,
109115
Map<String, String> environmentDefines, {
110116
bool verbose: false,
117+
NnbdMode nnbdMode: NnbdMode.Weak,
111118
}) async {
112119
// TODO(sigmund): use incremental compiler when it supports our use case.
113120
// Note: it is common for the summary worker to invoke the compiler with the
@@ -125,7 +132,8 @@ Future<InitializedCompilerState> initializeCompiler(
125132
..experimentalFlags = parseExperimentalFlags(
126133
parseExperimentalArguments(experiments),
127134
onError: (e) => throw e)
128-
..verbose = verbose;
135+
..verbose = verbose
136+
..nnbdMode = nnbdMode;
129137

130138
ProcessedOptions processedOpts = new ProcessedOptions(options: options);
131139

utils/bazel/kernel_worker.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ final summaryArgsParser = new ArgParser()
144144
..addMultiOption('enable-experiment',
145145
help: 'Enable a language experiment when invoking the CFE.')
146146
..addMultiOption('define', abbr: 'D')
147-
..addFlag('verbose', defaultsTo: false);
147+
..addFlag('verbose', defaultsTo: false)
148+
..addFlag('sound-null-safety', defaultsTo: false);
148149

149150
class ComputeKernelResult {
150151
final bool succeeded;
@@ -187,6 +188,9 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
187188
var sources = (parsedArgs['source'] as List<String>).map(_toUri).toList();
188189
var excludeNonSources = parsedArgs['exclude-non-sources'] as bool;
189190

191+
var nnbdMode = parsedArgs['sound-null-safety'] as bool
192+
? fe.NnbdMode.Strong
193+
: fe.NnbdMode.Weak;
190194
var summaryOnly = parsedArgs['summary-only'] as bool;
191195
var trackWidgetCreation = parsedArgs['track-widget-creation'] as bool;
192196

@@ -294,7 +298,8 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
294298
summaryOnly,
295299
environmentDefines,
296300
trackNeededDillLibraries: recordUsedInputs,
297-
verbose: verbose);
301+
verbose: verbose,
302+
nnbdMode: nnbdMode);
298303
} else {
299304
state = await fe.initializeCompiler(
300305
// TODO(sigmund): pass an old state once we can make use of it.
@@ -307,7 +312,8 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
307312
fileSystem,
308313
parsedArgs['enable-experiment'] as List<String>,
309314
environmentDefines,
310-
verbose: verbose);
315+
verbose: verbose,
316+
nnbdMode: nnbdMode);
311317
}
312318

313319
void onDiagnostic(fe.DiagnosticMessage message) {

0 commit comments

Comments
 (0)