| Index: pkg/compiler/lib/src/js_backend/impact_transformer.dart
|
| diff --git a/pkg/compiler/lib/src/js_backend/impact_transformer.dart b/pkg/compiler/lib/src/js_backend/impact_transformer.dart
|
| index 517fd908ebd22524ae5b05e1e90df8fa5cd02dc6..6b0cda4e1eead34002c4bfc1f346ff21e7da71fe 100644
|
| --- a/pkg/compiler/lib/src/js_backend/impact_transformer.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/impact_transformer.dart
|
| @@ -8,12 +8,13 @@ import '../common.dart';
|
| import '../common_elements.dart';
|
| import '../common/backend_api.dart' show ImpactTransformer;
|
| import '../common/codegen.dart' show CodegenImpact;
|
| -import '../common/resolution.dart' show Resolution, ResolutionImpact;
|
| +import '../common/resolution.dart' show ResolutionImpact;
|
| import '../constants/expressions.dart';
|
| import '../common_elements.dart' show ElementEnvironment;
|
| -import '../elements/elements.dart';
|
| +import '../elements/elements.dart' show AsyncMarker;
|
| import '../elements/entities.dart';
|
| -import '../elements/resolution_types.dart';
|
| +import '../elements/resolution_types.dart' show Types;
|
| +import '../elements/types.dart';
|
| import '../enqueue.dart' show ResolutionEnqueuer;
|
| import '../native/enqueue.dart';
|
| import '../native/native.dart' as native;
|
| @@ -37,7 +38,6 @@ import 'native_data.dart';
|
|
|
| class JavaScriptImpactTransformer extends ImpactTransformer {
|
| final CompilerOptions _options;
|
| - final Resolution _resolution;
|
| final ElementEnvironment _elementEnvironment;
|
| final CommonElements _commonElements;
|
| final BackendImpacts _impacts;
|
| @@ -50,7 +50,6 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
|
|
| JavaScriptImpactTransformer(
|
| this._options,
|
| - this._resolution,
|
| this._elementEnvironment,
|
| this._commonElements,
|
| this._impacts,
|
| @@ -152,7 +151,7 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
| bool hasAsCast = false;
|
| bool hasTypeLiteral = false;
|
| for (TypeUse typeUse in worldImpact.typeUses) {
|
| - ResolutionDartType type = typeUse.type;
|
| + DartType type = typeUse.type;
|
| switch (typeUse.kind) {
|
| case TypeUseKind.INSTANTIATION:
|
| case TypeUseKind.MIRROR_INSTANTIATION:
|
| @@ -176,15 +175,18 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
| break;
|
| case TypeUseKind.TYPE_LITERAL:
|
| _customElementsResolutionAnalysis.registerTypeLiteral(type);
|
| - if (type.isTypeVariable && type is! MethodTypeVariableType) {
|
| - // GENERIC_METHODS: The `is!` test above filters away method type
|
| - // variables, because they have the value `dynamic` with the
|
| - // incomplete support for generic methods offered with
|
| - // '--generic-method-syntax'. This must be revised in order to
|
| - // support generic methods fully.
|
| - ClassElement cls = type.element.enclosingClass;
|
| - _rtiNeedBuilder.registerClassUsingTypeVariableExpression(cls);
|
| - registerImpact(_impacts.typeVariableExpression);
|
| + if (type.isTypeVariable) {
|
| + TypeVariableType typeVariable = type;
|
| + if (typeVariable.element.typeDeclaration is ClassEntity) {
|
| + // GENERIC_METHODS: The `is!` test above filters away method type
|
| + // variables, because they have the value `dynamic` with the
|
| + // incomplete support for generic methods offered with
|
| + // '--generic-method-syntax'. This must be revised in order to
|
| + // support generic methods fully.
|
| + ClassEntity cls = typeVariable.element.typeDeclaration;
|
| + _rtiNeedBuilder.registerClassUsingTypeVariableExpression(cls);
|
| + registerImpact(_impacts.typeVariableExpression);
|
| + }
|
| }
|
| hasTypeLiteral = true;
|
| break;
|
| @@ -210,8 +212,7 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
| transformed
|
| .registerTypeUse(new TypeUse.instantiation(mapLiteralUse.type));
|
| }
|
| - ResolutionInterfaceType type = mapLiteralUse.type;
|
| - registerRequiredType(type);
|
| + registerRequiredType(mapLiteralUse.type);
|
| }
|
|
|
| for (ListLiteralUse listLiteralUse in worldImpact.listLiterals) {
|
| @@ -219,8 +220,7 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
| // factory constructors are registered directly.
|
| transformed
|
| .registerTypeUse(new TypeUse.instantiation(listLiteralUse.type));
|
| - ResolutionInterfaceType type = listLiteralUse.type;
|
| - registerRequiredType(type);
|
| + registerRequiredType(listLiteralUse.type);
|
| }
|
|
|
| if (worldImpact.constSymbolNames.isNotEmpty) {
|
| @@ -234,8 +234,9 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
| switch (staticUse.kind) {
|
| case StaticUseKind.CLOSURE:
|
| registerImpact(_impacts.closure);
|
| - LocalFunctionElement closure = staticUse.element;
|
| - if (closure.type.containsTypeVariables) {
|
| + Local closure = staticUse.element;
|
| + FunctionType type = _elementEnvironment.getLocalFunctionType(closure);
|
| + if (type.containsTypeVariables) {
|
| registerImpact(_impacts.computeSignature);
|
| }
|
| break;
|
| @@ -279,29 +280,30 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
| }
|
|
|
| /// Register [type] as required for the runtime type information system.
|
| - void registerRequiredType(ResolutionDartType type) {
|
| + void registerRequiredType(DartType type) {
|
| if (!type.isInterfaceType) return;
|
| + InterfaceType interfaceType = type;
|
| // If [argument] has type variables or is a type variable, this method
|
| // registers a RTI dependency between the class where the type variable is
|
| // defined (that is the enclosing class of the current element being
|
| // resolved) and the class of [type]. If the class of [type] requires RTI,
|
| // then the class of the type variable does too.
|
| - ClassElement contextClass = Types.getClassContext(type);
|
| + ClassEntity contextClass = Types.getClassContext(interfaceType);
|
| if (contextClass != null) {
|
| - _rtiNeedBuilder.registerRtiDependency(type.element, contextClass);
|
| + _rtiNeedBuilder.registerRtiDependency(
|
| + interfaceType.element, contextClass);
|
| }
|
| }
|
|
|
| // TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType].
|
| - void onIsCheck(ResolutionDartType type, TransformedWorldImpact transformed) {
|
| + void onIsCheck(DartType type, TransformedWorldImpact transformed) {
|
| void registerImpact(BackendImpact impact) {
|
| impact.registerImpact(transformed, _elementEnvironment);
|
| _backendUsageBuider.processBackendImpact(impact);
|
| }
|
|
|
| registerRequiredType(type);
|
| - type.computeUnaliased(_resolution);
|
| - type = type.unaliased;
|
| + type = _elementEnvironment.getUnaliasedType(type);
|
| registerImpact(_impacts.typeCheck);
|
|
|
| bool inCheckedMode = _options.enableTypeAssertions;
|
| @@ -323,11 +325,10 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
| }
|
| }
|
| }
|
| - if (type is ResolutionFunctionType) {
|
| + if (type is FunctionType) {
|
| registerImpact(_impacts.functionTypeCheck);
|
| }
|
| - if (type is ResolutionInterfaceType &&
|
| - _nativeBasicData.isNativeClass(type.element)) {
|
| + if (type is InterfaceType && _nativeBasicData.isNativeClass(type.element)) {
|
| registerImpact(_impacts.nativeTypeCheck);
|
| }
|
| }
|
| @@ -363,8 +364,7 @@ class CodegenImpactTransformer {
|
| this._lookupMapAnalysis,
|
| this._rtiChecksBuilder);
|
|
|
| - void onIsCheckForCodegen(
|
| - ResolutionDartType type, TransformedWorldImpact transformed) {
|
| + void onIsCheckForCodegen(DartType type, TransformedWorldImpact transformed) {
|
| if (type.isDynamic) return;
|
| type = type.unaliased;
|
| _impacts.typeCheck.registerImpact(transformed, _elementEnvironment);
|
| @@ -394,8 +394,7 @@ class CodegenImpactTransformer {
|
| if (!type.treatAsRaw || type.containsTypeVariables) {
|
| _impacts.genericIsCheck.registerImpact(transformed, _elementEnvironment);
|
| }
|
| - if (type is ResolutionInterfaceType &&
|
| - _nativeData.isNativeClass(type.element)) {
|
| + if (type is InterfaceType && _nativeData.isNativeClass(type.element)) {
|
| // We will neeed to add the "$is" and "$as" properties on the
|
| // JavaScript object prototype, so we make sure
|
| // [:defineProperty:] is compiled.
|
| @@ -407,7 +406,7 @@ class CodegenImpactTransformer {
|
| TransformedWorldImpact transformed = new TransformedWorldImpact(impact);
|
|
|
| for (TypeUse typeUse in impact.typeUses) {
|
| - ResolutionDartType type = typeUse.type;
|
| + DartType type = typeUse.type;
|
| switch (typeUse.kind) {
|
| case TypeUseKind.INSTANTIATION:
|
| _lookupMapAnalysis.registerInstantiatedType(type);
|
| @@ -419,7 +418,7 @@ class CodegenImpactTransformer {
|
| }
|
| }
|
|
|
| - for (Pair<ResolutionDartType, ResolutionDartType> check
|
| + for (Pair<DartType, DartType> check
|
| in impact.typeVariableBoundsSubtypeChecks) {
|
| _rtiChecksBuilder.registerTypeVariableBoundsSubtypeCheck(
|
| check.a, check.b);
|
| @@ -428,7 +427,7 @@ class CodegenImpactTransformer {
|
| for (StaticUse staticUse in impact.staticUses) {
|
| switch (staticUse.kind) {
|
| case StaticUseKind.CLOSURE:
|
| - LocalFunctionElement closure = staticUse.element;
|
| + Local closure = staticUse.element;
|
| if (_rtiNeed.localFunctionNeedsRti(closure)) {
|
| _impacts.computeSignature
|
| .registerImpact(transformed, _elementEnvironment);
|
| @@ -457,8 +456,8 @@ class CodegenImpactTransformer {
|
| }
|
| }
|
|
|
| - for (FunctionElement element in impact.asyncMarkers) {
|
| - switch (element.asyncMarker) {
|
| + for (AsyncMarker asyncMarker in impact.asyncMarkers) {
|
| + switch (asyncMarker) {
|
| case AsyncMarker.ASYNC:
|
| _impacts.asyncBody.registerImpact(transformed, _elementEnvironment);
|
| break;
|
|
|