[dart2js] Migrate js_emitter/constant_ordering.dart
Change-Id: I2270e470ca03b7abb750f56fe319b35412b68551
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245085
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
diff --git a/pkg/compiler/lib/src/constants/values.dart b/pkg/compiler/lib/src/constants/values.dart
index b12d2da..07fc1d5 100644
--- a/pkg/compiler/lib/src/constants/values.dart
+++ b/pkg/compiler/lib/src/constants/values.dart
@@ -86,6 +86,7 @@
List<ConstantValue> getDependencies();
+ // TODO(48820): Add type parameters.
accept(ConstantValueVisitor visitor, arg);
/// The value of this constant in Dart syntax, if possible.
diff --git a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
index 1cbf7e1..5932c85 100644
--- a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
+++ b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
@@ -68,7 +68,7 @@
return _nativeEmitter;
}
- Emitter get emitter {
+ Emitter /*!*/ get emitter {
assert(_emitter != null,
failedAt(NO_LOCATION_SPANNABLE, "Emitter has not been created yet."));
return _emitter;
diff --git a/pkg/compiler/lib/src/js_emitter/constant_ordering.dart b/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
index ed04b1c..3103cb2 100644
--- a/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
+++ b/pkg/compiler/lib/src/js_emitter/constant_ordering.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.10
-
library dart2js.js_emitter.constant_ordering;
import '../constants/values.dart';
@@ -22,7 +20,7 @@
class _ConstantOrdering
implements ConstantOrdering, ConstantValueVisitor<int, ConstantValue> {
final Sorter _sorter;
- _DartTypeOrdering _dartTypeOrdering;
+ late _DartTypeOrdering _dartTypeOrdering;
_ConstantOrdering(this._sorter) {
_dartTypeOrdering = _DartTypeOrdering(this);
}
@@ -37,7 +35,7 @@
return a.accept(this, b);
}
- static int compareLists<S, T>(int compare(S a, T b), List<S> a, List<T> b) {
+ static int compareLists<T>(int compare(T a, T b), List<T> a, List<T> b) {
int r = a.length.compareTo(b.length);
if (r != 0) return r;
for (int i = 0; i < a.length; i++) {
@@ -54,7 +52,7 @@
}
int compareMembers(MemberEntity a, MemberEntity b) {
- int r = a.name.compareTo(b.name);
+ int r = a.name!.compareTo(b.name!);
if (r != 0) return r;
return _sorter.compareMembersByLocation(a, b);
}
@@ -139,8 +137,8 @@
return compareLists(
compareValues,
- aFields.map((field) => a.fields[field]).toList(),
- aFields.map((field) => b.fields[field]).toList());
+ aFields.map((field) => a.fields[field]!).toList(),
+ aFields.map((field) => b.fields[field]!).toList());
}
@override
@@ -184,7 +182,8 @@
DeferredGlobalConstantValue a, DeferredGlobalConstantValue b) {
int r = compareValues(a.referenced, b.referenced);
if (r != 0) return r;
- return a.unit.compareTo(b.unit);
+ // TODO(48820): Should unit be non-nullable?
+ return a.unit!.compareTo(b.unit!);
}
@override
@@ -234,7 +233,7 @@
class _DartTypeOrdering extends DartTypeVisitor<int, DartType> {
final _ConstantOrdering _constantOrdering;
- DartType _root;
+ DartType? _root;
final List<FunctionTypeVariable> _leftFunctionTypeVariables = [];
final List<FunctionTypeVariable> _rightFunctionTypeVariables = [];
_DartTypeOrdering(this._constantOrdering);
diff --git a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
index 4d5beaf..7ba3a7f 100644
--- a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
@@ -420,7 +420,7 @@
CustomElementsCodegenAnalysis analysis = _customElementsCodegenAnalysis;
if (!analysis.needsTable) return null;
- List<jsAst.Expression> elements = [];
+ List<jsAst.Expression /*!*/ > elements = [];
Iterable<ConstantValue> constants =
_codegenWorld.getConstantsForEmission(_emitter.compareConstants);
for (ConstantValue constant in constants) {
diff --git a/pkg/compiler/lib/src/universe/codegen_world_builder.dart b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
index 710e2c4..73a25f6 100644
--- a/pkg/compiler/lib/src/universe/codegen_world_builder.dart
+++ b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
@@ -81,10 +81,10 @@
void forEachStaticField(void Function(FieldEntity) f);
/// Returns the types that are live as constant type literals.
- Iterable<DartType> get constTypeLiterals;
+ Iterable<DartType /*!*/ > get constTypeLiterals;
/// Returns the types that are live as constant type arguments.
- Iterable<DartType> get liveTypeArguments;
+ Iterable<DartType /*!*/ > get liveTypeArguments;
/// Returns a list of constants topologically sorted so that dependencies
/// appear before the dependent constant.
diff --git a/pkg/compiler/lib/src/universe/use.dart b/pkg/compiler/lib/src/universe/use.dart
index 9ddd60d..2adead4 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -899,7 +899,7 @@
class ConstantUse {
static const String tag = 'constant-use';
- final ConstantValue value;
+ final ConstantValue /*!*/ value;
ConstantUse._(this.value);
@@ -922,7 +922,7 @@
}
/// Constant used as the initial value of a field.
- ConstantUse.init(ConstantValue value) : this._(value);
+ ConstantUse.init(ConstantValue /*!*/ value) : this._(value);
/// Type constant used for registration of custom elements.
ConstantUse.customElements(TypeConstantValue value) : this._(value);