Index: pkg/compiler/lib/src/js_backend/type_variable_handler.dart |
diff --git a/pkg/compiler/lib/src/js_backend/type_variable_handler.dart b/pkg/compiler/lib/src/js_backend/type_variable_handler.dart |
index 996137d06c718aeb62d93b901c3a6ae9ebfcc1e4..617f8f5dd0ed9e3d788b4bef19b5468317d58551 100644 |
--- a/pkg/compiler/lib/src/js_backend/type_variable_handler.dart |
+++ b/pkg/compiler/lib/src/js_backend/type_variable_handler.dart |
@@ -5,8 +5,8 @@ |
import '../common_elements.dart'; |
import '../constants/expressions.dart'; |
import '../constants/values.dart'; |
-import '../elements/resolution_types.dart'; |
-import '../elements/elements.dart'; |
+import '../elements/entities.dart'; |
+import '../elements/types.dart'; |
import '../js/js.dart' as jsAst; |
import '../js_emitter/js_emitter.dart' |
show CodeEmitterTask, MetadataCollector, Placeholder; |
@@ -43,7 +43,7 @@ class TypeVariableResolutionAnalysis { |
return impactBuilder.flush(); |
} |
- void registerClassWithTypeVariables(ClassElement cls) { |
+ void registerClassWithTypeVariables(ClassEntity cls) { |
// On first encounter, we have to ensure that the support classes get |
// resolved. |
if (!_seenClassesWithTypeVariables) { |
@@ -57,6 +57,7 @@ class TypeVariableResolutionAnalysis { |
/// Codegen handler that creates TypeVariable constants needed at runtime. |
class TypeVariableCodegenAnalysis { |
+ final ElementEnvironment _elementEnvironment; |
final JavaScriptBackend _backend; |
final BackendHelpers _helpers; |
final MirrorsData _mirrorsData; |
@@ -65,21 +66,22 @@ class TypeVariableCodegenAnalysis { |
* Maps a class element to a list with indices that point to type variables |
* constants for each of the class' type variables. |
*/ |
- Map<ClassElement, List<jsAst.Expression>> _typeVariables = |
- new Map<ClassElement, List<jsAst.Expression>>(); |
+ Map<ClassEntity, List<jsAst.Expression>> _typeVariables = |
+ new Map<ClassEntity, List<jsAst.Expression>>(); |
/** |
* Maps a TypeVariableType to the index pointing to the constant representing |
* the corresponding type variable at runtime. |
*/ |
- Map<TypeVariableElement, jsAst.Expression> _typeVariableConstants = |
- new Map<TypeVariableElement, jsAst.Expression>(); |
+ Map<TypeVariableEntity, jsAst.Expression> _typeVariableConstants = |
+ new Map<TypeVariableEntity, jsAst.Expression>(); |
/// Impact builder used for the codegen world computation. |
final StagedWorldImpactBuilder _impactBuilder = |
new StagedWorldImpactBuilder(); |
- TypeVariableCodegenAnalysis(this._backend, this._helpers, this._mirrorsData); |
+ TypeVariableCodegenAnalysis(this._elementEnvironment, this._backend, |
+ this._helpers, this._mirrorsData); |
CodeEmitterTask get _task => _backend.emitter; |
MetadataCollector get _metadataCollector => _task.metadataCollector; |
@@ -90,32 +92,34 @@ class TypeVariableCodegenAnalysis { |
return _impactBuilder.flush(); |
} |
- void registerClassWithTypeVariables(ClassElement cls) { |
+ void registerClassWithTypeVariables(ClassEntity cls) { |
if (_mirrorsData.isClassAccessibleByReflection(cls)) { |
processTypeVariablesOf(cls); |
} |
} |
- void processTypeVariablesOf(ClassElement cls) { |
+ void processTypeVariablesOf(ClassEntity cls) { |
// Do not process classes twice. |
if (_typeVariables.containsKey(cls)) return; |
List<jsAst.Expression> constants = <jsAst.Expression>[]; |
- for (ResolutionTypeVariableType currentTypeVariable in cls.typeVariables) { |
- TypeVariableElement typeVariableElement = currentTypeVariable.element; |
+ InterfaceType thisType = _elementEnvironment.getThisType(cls); |
+ for (TypeVariableType currentTypeVariable in thisType.typeArguments) { |
+ TypeVariableEntity typeVariableElement = currentTypeVariable.element; |
- jsAst.Expression boundIndex = |
- _metadataCollector.reifyType(typeVariableElement.bound); |
+ jsAst.Expression boundIndex = _metadataCollector.reifyType( |
+ _elementEnvironment.getTypeVariableBound(typeVariableElement)); |
ConstantValue boundValue = new SyntheticConstantValue( |
SyntheticConstantKind.TYPEVARIABLE_REFERENCE, boundIndex); |
- ClassElement typeVariableClass = _helpers.typeVariableClass; |
+ ClassEntity typeVariableClass = _helpers.typeVariableClass; |
ConstantExpression constant = new ConstructedConstantExpression( |
- typeVariableClass.thisType, |
+ _elementEnvironment.getThisType(typeVariableClass), |
_helpers.typeVariableConstructor, |
const CallStructure.unnamed(3), [ |
- new TypeConstantExpression(cls.rawType, cls.name), |
- new StringConstantExpression(currentTypeVariable.name), |
+ new TypeConstantExpression( |
+ _elementEnvironment.getRawType(cls), cls.name), |
+ new StringConstantExpression(typeVariableElement.name), |
new SyntheticConstantExpression(boundValue) |
]); |
@@ -138,7 +142,7 @@ class TypeVariableCodegenAnalysis { |
* there, otherwise a new entry for [c] is created. |
*/ |
jsAst.Expression _reifyTypeVariableConstant( |
- ConstantValue c, TypeVariableElement variable) { |
+ ConstantValue c, TypeVariableEntity variable) { |
jsAst.Expression name = _task.constantReference(c); |
jsAst.Expression result = _metadataCollector.reifyExpression(name); |
if (_typeVariableConstants.containsKey(variable)) { |
@@ -159,7 +163,7 @@ class TypeVariableCodegenAnalysis { |
* [reifyTypeVariableConstant] will be called and the constant will be added |
* on the allocated entry. |
*/ |
- jsAst.Expression reifyTypeVariable(TypeVariableElement variable) { |
+ jsAst.Expression reifyTypeVariable(TypeVariableEntity variable) { |
if (_typeVariableConstants.containsKey(variable)) { |
return _typeVariableConstants[variable]; |
} |
@@ -169,7 +173,7 @@ class TypeVariableCodegenAnalysis { |
return _typeVariableConstants[variable] = placeholder; |
} |
- List<jsAst.Expression> typeVariablesOf(ClassElement classElement) { |
+ List<jsAst.Expression> typeVariablesOf(ClassEntity classElement) { |
List<jsAst.Expression> result = _typeVariables[classElement]; |
if (result == null) { |
result = const <jsAst.Expression>[]; |