diff --git a/pkg/dev_compiler/lib/src/compiler/module_containers.dart b/pkg/dev_compiler/lib/src/compiler/module_containers.dart index 8e954be110a..8150de593ef 100644 --- a/pkg/dev_compiler/lib/src/compiler/module_containers.dart +++ b/pkg/dev_compiler/lib/src/compiler/module_containers.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import '../compiler/js_names.dart' as js_ast; import '../js_ast/js_ast.dart' as js_ast; import '../js_ast/js_ast.dart' show js; @@ -78,7 +76,7 @@ abstract class ModuleItemContainer { /// Creates an automatically sharding container backed by JS Objects. factory ModuleItemContainer.asObject(String name, - {String Function(K) keyToString}) { + {required String Function(K) keyToString}) { return ModuleItemObjectContainer(name, keyToString); } @@ -95,7 +93,7 @@ abstract class ModuleItemContainer { bool get isEmpty => moduleItems.isEmpty; - js_ast.Expression operator [](K key) => moduleItems[key]?.jsValue; + js_ast.Expression? operator [](K key) => moduleItems[key]?.jsValue; void operator []=(K key, js_ast.Expression value); @@ -125,7 +123,7 @@ abstract class ModuleItemContainer { /// necessary. /// /// Uses [emitValue] to emit the values in the table. - List emit({EmitValue emitValue}); + List emit({EmitValue? emitValue}); } /// Associates a [K] with a container-unique JS key and arbitrary JS value. @@ -157,7 +155,7 @@ class ModuleItemObjectContainer extends ModuleItemContainer { @override void operator []=(K key, js_ast.Expression value) { if (contains(key)) { - moduleItems[key].jsValue = value; + moduleItems[key]!.jsValue = value; return; } // Create a unique name for K when emitted as a JS field. @@ -179,12 +177,12 @@ class ModuleItemObjectContainer extends ModuleItemContainer { @override js_ast.Expression access(K key) { - var id = moduleItems[key].id; - return js.call('#.#', [id, moduleItems[key].jsKey]); + var id = moduleItems[key]!.id; + return js.call('#.#', [id, moduleItems[key]!.jsKey]); } @override - List emit({EmitValue emitValue}) { + List emit({EmitValue? emitValue}) { var containersToProperties = >{}; moduleItems.forEach((k, v) { if (!incrementalMode && _noEmit.contains(k)) return; @@ -193,7 +191,7 @@ class ModuleItemObjectContainer extends ModuleItemContainer { if (!containersToProperties.containsKey(v.id)) { containersToProperties[v.id] = []; } - containersToProperties[v.id].add(js_ast.Property( + containersToProperties[v.id]!.add(js_ast.Property( v.jsKey, emitValue == null ? v.jsValue : emitValue(k, v))); }); @@ -226,7 +224,7 @@ class ModuleItemArrayContainer extends ModuleItemContainer { @override void operator []=(K key, js_ast.Expression value) { if (moduleItems.containsKey(key)) { - moduleItems[key].jsValue = value; + moduleItems[key]!.jsValue = value; return; } moduleItems[key] = @@ -236,12 +234,13 @@ class ModuleItemArrayContainer extends ModuleItemContainer { @override js_ast.Expression access(K key) { var id = containerId; - return js.call('#[#]', [id, moduleItems[key].jsKey]); + return js.call('#[#]', [id, moduleItems[key]!.jsKey]); } @override - List emit({EmitValue emitValue}) { - var properties = List.filled(length, null); + List emit({EmitValue? emitValue}) { + var dummyExpression = js_ast.TemporaryId('dummyExpression'); + var properties = List.filled(length, dummyExpression); // If the entire array holds just one value, generate a short initializer. var valueSet = {};