[dart2js] migrate resolution_listener.dart

Change-Id: I4fcb759ce8b65a59952506ff83462b92859c13eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262275
Reviewed-by: Nate Biggs <natebiggs@google.com>
This commit is contained in:
Sigmund Cherem 2022-10-03 17:49:56 +00:00 committed by Commit Queue
parent 7ab05daa4b
commit 9768f74c59
2 changed files with 11 additions and 11 deletions

View file

@ -44,7 +44,7 @@ abstract class EnqueuerListener {
WorldImpact registerUsedConstant(ConstantValue value);
void onQueueOpen(
Enqueuer enqueuer, FunctionEntity mainMethod, Iterable<Uri> libraries);
Enqueuer enqueuer, FunctionEntity? mainMethod, Iterable<Uri> libraries);
/// Called when [enqueuer]'s queue is empty, but before it is closed.
///
@ -115,7 +115,7 @@ abstract class Enqueuer {
void processConstantUse(ConstantUse constantUse);
EnqueuerListener get listener;
void open(FunctionEntity mainMethod, Iterable<Uri> libraries) {
void open(FunctionEntity? mainMethod, Iterable<Uri> libraries) {
listener.onQueueOpen(this, mainMethod, libraries);
}

View file

@ -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 js_backend.backend.resolution_listener;
import '../common/elements.dart' show KCommonElements, KElementEnvironment;
@ -13,6 +11,7 @@ import '../deferred_load/deferred_load.dart';
import '../elements/entities.dart';
import '../elements/types.dart';
import '../enqueue.dart' show Enqueuer, EnqueuerListener;
import '../kernel/kelements.dart' show KClass;
import '../native/enqueue.dart';
import '../options.dart' show CompilerOptions;
import '../universe/call_structure.dart' show CallStructure;
@ -137,7 +136,7 @@ class ResolutionEnqueuerListener extends EnqueuerListener {
@override
void onQueueOpen(
Enqueuer enqueuer, FunctionEntity mainMethod, Iterable<Uri> libraries) {
Enqueuer enqueuer, FunctionEntity? mainMethod, Iterable<Uri> libraries) {
if (_deferredLoadTask.isProgramSplit) {
enqueuer.applyImpact(_computeDeferredLoadingImpact());
}
@ -160,13 +159,13 @@ class ResolutionEnqueuerListener extends EnqueuerListener {
enqueuer.applyImpact(_customElementsAnalysis.flush());
for (ClassEntity cls in recentClasses) {
MemberEntity element =
MemberEntity? element =
_elementEnvironment.lookupLocalClassMember(cls, Names.noSuchMethod_);
if (element != null &&
element.isInstanceMember &&
element.isFunction &&
!element.isAbstract) {
_noSuchMethodRegistry.registerNoSuchMethod(element);
_noSuchMethodRegistry.registerNoSuchMethod(element as FunctionEntity);
}
}
_noSuchMethodRegistry.onQueueEmpty();
@ -253,7 +252,7 @@ class ResolutionEnqueuerListener extends EnqueuerListener {
_customElementsAnalysis.registerStaticUse(member);
if (member.isFunction) {
FunctionEntity function = member;
FunctionEntity function = member as FunctionEntity;
if (function.isExternal) {
FunctionType functionType =
_elementEnvironment.getFunctionType(function);
@ -275,7 +274,7 @@ class ResolutionEnqueuerListener extends EnqueuerListener {
}
}
if (function.isInstanceMember) {
ClassEntity cls = function.enclosingClass;
ClassEntity cls = function.enclosingClass!;
if (function.name == Identifiers.call &&
_elementEnvironment.isGenericClass(cls)) {
@ -421,7 +420,7 @@ class ResolutionEnqueuerListener extends EnqueuerListener {
@override
WorldImpact registerInstantiatedClass(ClassEntity cls) {
_fieldAnalysis.registerInstantiatedClass(cls);
_fieldAnalysis.registerInstantiatedClass(cls as KClass);
return _processClass(cls);
}
@ -458,7 +457,8 @@ class ResolutionEnqueuerListener extends EnqueuerListener {
// TODO(13155): Find a way to register fewer _commonElements.
List<FunctionEntity> staticUses = [];
for (CheckedModeHelper helper in CheckedModeHelpers.helpers) {
staticUses.add(helper.getStaticUse(_commonElements).element);
staticUses
.add(helper.getStaticUse(_commonElements).element as FunctionEntity);
}
_registerBackendImpact(
impactBuilder, BackendImpact(globalUses: staticUses));