diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart index de15eb3a694..38426dbc06a 100644 --- a/pkg/compiler/lib/src/kernel/element_map_impl.dart +++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart @@ -60,6 +60,7 @@ import 'element_map_interfaces.dart' as interfaces show KernelElementEnvironment, KernelToElementMapForClassHierarchy, + KernelToElementMapForEnv, KernelToElementMapForImpactData, KernelToElementMapForKernelImpact, KernelToElementMapForNativeData, @@ -74,6 +75,7 @@ import 'kernel_impact.dart'; class KernelToElementMap implements interfaces.KernelToElementMapForClassHierarchy, + interfaces.KernelToElementMapForEnv, interfaces.KernelToElementMapForImpactData, interfaces.KernelToElementMapForNativeData, interfaces.KernelToElementMapForDeferredLoading, @@ -287,6 +289,7 @@ class KernelToElementMap return types.interfaceType(getClass(cls), getDartTypes(typeArguments)); } + @override LibraryEntity getLibrary(ir.Library node) => getLibraryInternal(node); /// Returns the [ClassEntity] corresponding to the class [node]. @@ -1210,6 +1213,7 @@ class KernelToElementMap } /// Converts [annotations] into a list of [ConstantValue]s. + @override List getMetadata( ir.StaticTypeContext staticTypeContext, List annotations) { if (annotations.isEmpty) return const []; diff --git a/pkg/compiler/lib/src/kernel/element_map_interfaces.dart b/pkg/compiler/lib/src/kernel/element_map_interfaces.dart index 203cee35008..c0756f06ad8 100644 --- a/pkg/compiler/lib/src/kernel/element_map_interfaces.dart +++ b/pkg/compiler/lib/src/kernel/element_map_interfaces.dart @@ -14,6 +14,7 @@ import 'package:kernel/ast.dart' as ir Expression, Field, InterfaceType, + Library, LibraryDependency, LocalFunction, Member, @@ -31,6 +32,7 @@ import '../elements/entities.dart' ConstructorEntity, FieldEntity, FunctionEntity, + LibraryEntity, Local, MemberEntity, ImportEntity; @@ -166,6 +168,13 @@ abstract class KernelToElementMapForJsModel implements IrToElementMap { set envIsClosed(bool v); } +abstract class KernelToElementMapForEnv implements IrToElementMap { + ir.TypeEnvironment get typeEnvironment; + LibraryEntity getLibrary(ir.Library node); + List getMetadata( + ir.StaticTypeContext staticTypeContext, List annotations); +} + // Members which dart2js ignores. bool memberIsIgnorable(ir.Member node, {ir.Class? cls}) { if (node is! ir.Procedure) return false; diff --git a/pkg/compiler/lib/src/kernel/env.dart b/pkg/compiler/lib/src/kernel/env.dart index 10337468dc8..3dc3a5ce55f 100644 --- a/pkg/compiler/lib/src/kernel/env.dart +++ b/pkg/compiler/lib/src/kernel/env.dart @@ -26,8 +26,8 @@ import '../js_model/element_map.dart'; import '../js_model/env.dart'; import '../ordered_typeset.dart'; import '../universe/member_usage.dart'; -import 'element_map.dart'; -import 'element_map_interfaces.dart' show memberIsIgnorable; +import 'element_map_interfaces.dart' + show memberIsIgnorable, KernelToElementMapForEnv; import 'env_interfaces.dart' as interfaces; @@ -206,14 +206,14 @@ class KLibraryData implements interfaces.KLibraryData { KLibraryData(this.library); - Iterable getMetadata(KernelToElementMap elementMap) { + Iterable getMetadata(KernelToElementMapForEnv elementMap) { return _metadata ??= elementMap.getMetadata( ir.StaticTypeContext.forAnnotations( library, elementMap.typeEnvironment), library.annotations); } - Iterable getImports(KernelToElementMap elementMap) { + Iterable getImports(KernelToElementMapForEnv elementMap) { if (imports == null) { List dependencies = library.dependencies; if (dependencies.isEmpty) { @@ -257,7 +257,7 @@ abstract class KClassEnv implements interfaces.KClassEnv { bool get isMixinApplicationWithMembers; /// Ensures that all members have been computed for [cls]. - void ensureMembers(KernelToElementMap elementMap); + void ensureMembers(KernelToElementMapForEnv elementMap); /// Return the [MemberEntity] for the member [name] in the class. MemberEntity lookupMember(IrToElementMap elementMap, Name name); @@ -339,11 +339,11 @@ class KClassEnvImpl implements KClassEnv { } @override - void ensureMembers(KernelToElementMap elementMap) { + void ensureMembers(KernelToElementMapForEnv elementMap) { _ensureMaps(elementMap); } - void _ensureMaps(KernelToElementMap elementMap) { + void _ensureMaps(KernelToElementMapForEnv elementMap) { if (_memberMap != null) return; _memberMap = {}; @@ -580,7 +580,8 @@ class KClassDataImpl implements KClassData { bool isCallTypeComputed = false; @override - Iterable getMetadata(covariant KernelToElementMap elementMap) { + Iterable getMetadata( + covariant KernelToElementMapForEnv elementMap) { return _metadata ??= elementMap.getMetadata( ir.StaticTypeContext.forAnnotations( node.enclosingLibrary, elementMap.typeEnvironment), @@ -626,7 +627,8 @@ abstract class KMemberDataImpl implements KMemberData { KMemberDataImpl(this.node); @override - Iterable getMetadata(covariant KernelToElementMap elementMap) { + Iterable getMetadata( + covariant KernelToElementMapForEnv elementMap) { return _metadata ??= elementMap.getMetadata( ir.StaticTypeContext(node, elementMap.typeEnvironment), node.annotations); @@ -658,7 +660,7 @@ abstract class KFunctionDataMixin implements KFunctionData { @override List /*!*/ getFunctionTypeVariables( - covariant KernelToElementMap elementMap) { + covariant KernelToElementMapForEnv elementMap) { if (_typeVariables == null) { if (functionNode.typeParameters.isEmpty) { _typeVariables = const []; @@ -693,7 +695,7 @@ class KFunctionDataImpl extends KMemberDataImpl KFunctionDataImpl(ir.Member node, this.functionNode) : super(node); @override - FunctionType getFunctionType(covariant KernelToElementMap elementMap) { + FunctionType getFunctionType(covariant KernelToElementMapForEnv elementMap) { return _type ??= elementMap.getFunctionType(functionNode); } @@ -793,7 +795,7 @@ class KFieldDataImpl extends KMemberDataImpl implements KFieldData { ir.Field get node => super.node; @override - DartType getFieldType(covariant KernelToElementMap elementMap) { + DartType getFieldType(covariant KernelToElementMapForEnv elementMap) { return _type ??= elementMap.getDartType(node.type); }