Skip to content

Commit 06d9380

Browse files
johnniwintherCommit Queue
authored andcommitted
[kernel] Remove NonNullableByDefaultCompiledMode
and TargetFlags.soundNullSafety TEST=existing Change-Id: I5e28d3d187b0f84fa23130c042fd3c55b89c687c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413460 Reviewed-by: Ömer Ağacan <[email protected]> Reviewed-by: Jens Johansen <[email protected]> Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Nate Biggs <[email protected]>
1 parent 4884112 commit 06d9380

File tree

56 files changed

+81
-698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+81
-698
lines changed

pkg/compiler/lib/src/compiler.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,12 @@ class Compiler {
310310
irLibraries.add(irLibraryMap[library]!);
311311
}
312312
var mainMethod = component.mainMethodName;
313-
var componentMode = component.mode;
314313
final trimmedComponent = ir.Component(
315314
libraries: irLibraries,
316315
uriToSource: component.uriToSource,
317316
nameRoot: component.root,
318317
);
319-
trimmedComponent.setMainMethodAndMode(mainMethod, true, componentMode);
318+
trimmedComponent.setMainMethodAndMode(mainMethod, true);
320319
return trimmedComponent;
321320
}
322321

pkg/compiler/lib/src/phase/load_kernel.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Future<_LoadFromKernelResult> _loadFromKernel(
242242
if (options.entryUri != null) {
243243
entryLibrary = _findEntryLibrary(component, options.entryUri!);
244244
var mainMethod = _findMainMethod(entryLibrary);
245-
component.setMainMethodAndMode(mainMethod, true, component.mode);
245+
component.setMainMethodAndMode(mainMethod, true);
246246
}
247247

248248
_doTransformsOnKernelLoad(component, options, reporter);

pkg/dart2wasm/lib/dynamic_modules.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ class DynamicModuleStrategy extends DefaultModuleStrategy with KernelNodes {
250250
if (hasPragma(coreTypes, library, _mainLibPragma)) {
251251
final mainMethod = library.procedures
252252
.firstWhere((m) => hasPragma(coreTypes, m, _mainMethodPragma));
253-
component.setMainMethodAndMode(
254-
mainMethod.reference, true, component.mode);
253+
component.setMainMethodAndMode(mainMethod.reference, true);
255254
}
256255
}
257256
}

pkg/dev_compiler/lib/src/command/command.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,13 +839,8 @@ ModuleSymbols _emitSymbols(Compiler compiler, String moduleName,
839839

840840
ModuleMetadata _emitMetadata(js_ast.Program program, Component component,
841841
String sourceMapUri, String moduleUri, String? fullDillUri) {
842-
var metadata = ModuleMetadata(
843-
program.name!,
844-
loadFunctionName(program.name!),
845-
sourceMapUri,
846-
moduleUri,
847-
fullDillUri,
848-
component.mode == NonNullableByDefaultCompiledMode.Strong);
842+
var metadata = ModuleMetadata(program.name!, loadFunctionName(program.name!),
843+
sourceMapUri, moduleUri, fullDillUri);
849844

850845
for (var lib in component.libraries) {
851846
metadata.addLibrary(LibraryMetadata(

pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,7 @@ class ExpressionCompilerWorker {
429429
libraries: libraries,
430430
nameRoot: originalComponent.root,
431431
uriToSource: originalComponent.uriToSource,
432-
)..setMainMethodAndMode(
433-
originalComponent.mainMethodName, true, originalComponent.mode);
432+
)..setMainMethodAndMode(originalComponent.mainMethodName, true);
434433
_processedOptions.ticker.logMs('Collected libraries for $moduleName');
435434
}
436435

@@ -491,8 +490,7 @@ class ExpressionCompilerWorker {
491490
libraries: librariesToEmit,
492491
nameRoot: finalComponent.root,
493492
uriToSource: finalComponent.uriToSource)
494-
..setMainMethodAndMode(
495-
originalComponent.mainMethodName, true, originalComponent.mode);
493+
..setMainMethodAndMode(originalComponent.mainMethodName, true);
496494

497495
kernel2jsCompiler.emitModule(componentToEmit);
498496
_processedOptions.ticker.logMs('Emitted module for expression');

pkg/dev_compiler/lib/src/kernel/module_metadata.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,8 @@ class ModuleMetadata {
127127

128128
final Map<String, LibraryMetadata> libraries = {};
129129

130-
/// True if the module corresponding to this metadata was compiled with sound
131-
/// null safety enabled.
132-
final bool soundNullSafety;
133-
134130
ModuleMetadata(this.name, this.closureName, this.sourceMapUri, this.moduleUri,
135-
this.fullDillUri, this.soundNullSafety,
131+
this.fullDillUri,
136132
{String? version})
137133
: version = version ??= ModuleMetadataVersion.current.version;
138134

@@ -157,8 +153,7 @@ class ModuleMetadata {
157153
closureName = json['closureName'] as String,
158154
sourceMapUri = json['sourceMapUri'] as String,
159155
moduleUri = json['moduleUri'] as String,
160-
fullDillUri = json['fullDillUri'] as String,
161-
soundNullSafety = json['soundNullSafety'] as bool {
156+
fullDillUri = json['fullDillUri'] as String {
162157
if (!ModuleMetadataVersion.current.isCompatibleWith(version)) {
163158
throw Exception('Unsupported metadata version $version');
164159
}
@@ -176,8 +171,7 @@ class ModuleMetadata {
176171
'sourceMapUri': sourceMapUri,
177172
'moduleUri': moduleUri,
178173
'fullDillUri': fullDillUri,
179-
'libraries': [for (var lib in libraries.values) lib.toJson()],
180-
'soundNullSafety': soundNullSafety
174+
'libraries': [for (var lib in libraries.values) lib.toJson()]
181175
};
182176
}
183177
}

pkg/dev_compiler/test/module_metadata_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void main() {
112112
}
113113

114114
ModuleMetadata createMetadata(String version) => ModuleMetadata(
115-
'module', 'closure', 'module.map', 'module.js', 'module.full.dill', true,
115+
'module', 'closure', 'module.map', 'module.js', 'module.full.dill',
116116
version: version)
117117
..addLibrary(LibraryMetadata('library', 'package:library/test.dart',
118118
'file:///source/library/lib/test.dart', ['src/test2.dart']));
@@ -125,7 +125,6 @@ void testMetadataFields(ModuleMetadata module, String version) {
125125
expect(module.sourceMapUri, 'module.map');
126126
expect(module.moduleUri, 'module.js');
127127
expect(module.fullDillUri, 'module.full.dill');
128-
expect(module.soundNullSafety, true);
129128

130129
var libUri = module.libraries.keys.first;
131130
var lib = module.libraries[libUri]!;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class DdcResult {
8080
Component _computeCompiledLibraries() {
8181
Component compiledLibraries = new Component(
8282
nameRoot: component.root, uriToSource: component.uriToSource)
83-
..setMainMethodAndMode(null, false, component.mode);
83+
..setMainMethodAndMode(null, false);
8484
for (Library lib in component.libraries) {
8585
if (!librariesFromDill.contains(lib)) {
8686
compiledLibraries.libraries.add(lib);

pkg/front_end/lib/src/base/incremental_compiler.dart

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import 'package:kernel/binary/ast_from_binary.dart'
1414
CompilationModeError,
1515
InvalidKernelSdkVersionError,
1616
InvalidKernelVersionError,
17-
SubComponentView,
18-
mergeCompilationModeOrThrow;
17+
SubComponentView;
1918
import 'package:kernel/canonical_name.dart'
2019
show CanonicalNameError, CanonicalNameSdkError;
2120
import 'package:kernel/class_hierarchy.dart'
@@ -39,7 +38,6 @@ import 'package:kernel/kernel.dart'
3938
Name,
4039
NamedNode,
4140
Node,
42-
NonNullableByDefaultCompiledMode,
4341
Procedure,
4442
ProcedureKind,
4543
Reference,
@@ -492,14 +490,9 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
492490
data.component?.mainMethod
493491
: componentWithDill.mainMethod;
494492
// ignore: unnecessary_null_comparison
495-
NonNullableByDefaultCompiledMode? compiledMode = componentWithDill == null
496-
?
497-
// Coverage-ignore(suite): Not run.
498-
data.component?.mode
499-
: componentWithDill.mode;
500493
Component result = context.options.target.configureComponent(
501494
new Component(libraries: outputLibraries, uriToSource: uriToSource))
502-
..setMainMethodAndMode(mainMethod?.reference, true, compiledMode!)
495+
..setMainMethodAndMode(mainMethod?.reference, true)
503496
..problemsAsJson = problemsAsJson;
504497

505498
// Copy the metadata *just created*. This will likely not contain metadata
@@ -944,28 +937,9 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
944937
_dillLoadedData!.loader.currentSourceLoader = kernelTarget.loader;
945938

946939
// Re-use the libraries we've deemed re-usable.
947-
List<bool> seenModes = [false, false, false, false];
948940
for (DillLibraryBuilder library in reusedLibraries) {
949-
seenModes[library.library.nonNullableByDefaultCompiledMode.index] = true;
950941
kernelTarget.loader.registerLoadedDillLibraryBuilder(library);
951942
}
952-
// Check compilation mode up against what we've seen here and set
953-
// `hasInvalidNnbdModeLibrary` accordingly.
954-
if (c.options.globalFeatures.nonNullable.isEnabled) {
955-
// Don't expect weak or invalid.
956-
if (seenModes[NonNullableByDefaultCompiledMode.Weak.index] ||
957-
seenModes[NonNullableByDefaultCompiledMode.Invalid.index]) {
958-
// Coverage-ignore-block(suite): Not run.
959-
kernelTarget.loader.hasInvalidNnbdModeLibrary = true;
960-
}
961-
} else {
962-
// Coverage-ignore-block(suite): Not run.
963-
// Don't expect strong or invalid.
964-
if (seenModes[NonNullableByDefaultCompiledMode.Strong.index] ||
965-
seenModes[NonNullableByDefaultCompiledMode.Invalid.index]) {
966-
kernelTarget.loader.hasInvalidNnbdModeLibrary = true;
967-
}
968-
}
969943

970944
// The entry point(s) has to be set first for loader.firstUri to be setup
971945
// correctly.
@@ -2491,8 +2465,7 @@ class _InitializationFromComponent extends _InitializationStrategy {
24912465
.mainMethod
24922466
// Coverage-ignore(suite): Not run.
24932467
?.reference,
2494-
true,
2495-
componentToInitializeFrom.mode);
2468+
true);
24962469
componentProblems.saveComponentProblems(component);
24972470

24982471
bool foundDartCore = false;
@@ -2621,10 +2594,6 @@ class _InitializationFromUri extends _InitializationFromSdkSummary {
26212594
.readComponent(data.component!,
26222595
checkCanonicalNames: true, createView: true)!;
26232596

2624-
// Compute "output nnbd mode".
2625-
NonNullableByDefaultCompiledMode compiledMode =
2626-
NonNullableByDefaultCompiledMode.Strong;
2627-
26282597
// Check the any package-urls still point to the same file
26292598
// (e.g. the package still exists and hasn't been updated).
26302599
// Also verify NNBD settings.
@@ -2638,16 +2607,6 @@ class _InitializationFromUri extends _InitializationFromSdkSummary {
26382607
// For now just don't initialize from this dill.
26392608
throw const PackageChangedError();
26402609
}
2641-
// Note: If a library has a NonNullableByDefaultCompiledMode.invalid
2642-
// we will throw and we won't initialize from it.
2643-
// That's wanted behavior.
2644-
if (compiledMode !=
2645-
mergeCompilationModeOrThrow(
2646-
compiledMode, lib.nonNullableByDefaultCompiledMode)) {
2647-
throw new CompilationModeError(
2648-
"Can't compile to $compiledMode with library with mode "
2649-
"${lib.nonNullableByDefaultCompiledMode}.");
2650-
}
26512610
}
26522611

26532612
// Only initialize the incremental serializer when we know we'll

pkg/front_end/lib/src/base/incremental_serializer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class IncrementalSerializer {
298298
libraries: libraries,
299299
uriToSource: component.uriToSource,
300300
nameRoot: component.root);
301-
singlePackageLibraries.setMainMethodAndMode(null, false, component.mode);
301+
singlePackageLibraries.setMainMethodAndMode(null, false);
302302

303303
// Copy all metadata. This should be okay (e.g. not result in a leak)
304304
// because we serialize now and then (implicitly) throw this component away.

0 commit comments

Comments
 (0)