| Index: dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
|
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
|
| index 53285fd7cd97b9cf0f03e28ebc2a9063c19b34d4..dbf20b8167c6f0121b3637b232aba146dbade109 100644
|
| --- a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
|
| +++ b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
|
| @@ -42,6 +42,8 @@ class ClassEmitter extends CodeEmitterHelper {
|
| emitInstanceMembers(classElement, builder, onlyForRti: onlyForRti);
|
| task.typeTestEmitter.emitIsTests(classElement, builder);
|
|
|
| + emitTypeVariableReaders(classElement, builder);
|
| +
|
| emitClassBuilderWithReflectionData(
|
| className, classElement, builder, buffer);
|
| }
|
| @@ -601,4 +603,45 @@ class ClassEmitter extends CodeEmitterHelper {
|
| builder.addProperty('+$reflectionName', reflectable);
|
| }
|
| }
|
| +
|
| + void emitTypeVariableReaders(ClassElement cls, ClassBuilder builder) {
|
| + List typeVariables = [];
|
| + ClassElement superclass = cls;
|
| + while (superclass != null) {
|
| + GenericType type = superclass.thisType;
|
| + for (TypeVariableType parameter in type.typeArguments) {
|
| + if (task.readTypeVariables.contains(parameter.element)) {
|
| + emitTypeVariableReader(cls, builder, parameter.element);
|
| + }
|
| + }
|
| + superclass = superclass.superclass;
|
| + }
|
| + }
|
| +
|
| + void emitTypeVariableReader(ClassElement cls,
|
| + ClassBuilder builder,
|
| + TypeVariableElement element) {
|
| + String name = namer.readTypeVariableName(element);
|
| + jsAst.Expression index =
|
| + js.toExpression(RuntimeTypes.getTypeVariableIndex(element));
|
| + jsAst.Expression computeTypeVariable;
|
| +
|
| + if (!backend.rti.isTrivialSubstitution(cls, element.enclosingElement)) {
|
| + Substitution substitution =
|
| + backend.rti.computeSubstitution(
|
| + cls, element.enclosingElement, alwaysGenerateFunction: true);
|
| + jsAst.Expression typeArguments =
|
| + substitution.getCode(backend.rti, true)['apply'](
|
| + ['null', r'this.$builtinTypeInfo']);
|
| + computeTypeVariable = typeArguments[index];
|
| + } else {
|
| + computeTypeVariable =
|
| + js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index);
|
| + }
|
| + jsAst.Expression convertRtiToRuntimeType =
|
| + namer.elementAccess(compiler.findHelper('convertRtiToRuntimeType'));
|
| + builder.addProperty(
|
| + name, js.fun(
|
| + [], [js.return_(convertRtiToRuntimeType(computeTypeVariable))]));
|
| + }
|
| }
|
|
|