Chromium Code Reviews| 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..7d6499f2f4a40e6fd497412dc183a44b9bd41fce 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,38 @@ 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; |
|
Johnni Winther
2013/10/30 11:40:23
The superclass chain is not properly substuted. Fo
Johnni Winther
2013/10/30 12:02:19
Actually you will visit C<U>, B<S>, A<T> if [cls]
ahe
2013/10/30 12:04:05
I don't think that is enough.
Consider this situa
|
| + } |
| + } |
| + |
| + void emitTypeVariableReader(ClassElement cls, |
| + ClassBuilder builder, |
| + TypeVariableElement element) { |
| + String name = namer.readTypeVariableName(element); |
| + List<jsAst.Node> body; |
| + if (cls != element.enclosingElement) { |
| + body = <jsAst.Node>[ |
| + new jsAst.Throw(js.string('Cannot read type variable ${element}'))]; |
|
ahe
2013/10/29 22:42:49
This is the only thing that causes tests to fail,
Johnni Winther
2013/10/30 11:40:23
The change above should solve this.
|
| + } else { |
| + body = <jsAst.Node>[ |
| + js.return_( |
| + namer.elementAccess( |
| + compiler.findHelper('convertRtiToRuntimeType'))( |
| + js(r'this.$builtinTypeInfo[#]', |
| + js.toExpression( |
| + RuntimeTypes.getTypeVariableIndex(element)))))]; |
| + } |
| + builder.addProperty(name, js.fun([], body)); |
| + } |
| } |