Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart

Issue 27689002: Reapply "Add TypeVariable object on runtime to support reflection on type variables." and … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix: include classes with members needed for reflection. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
index f483d2362c5e572a88b01c15a9cda15a16e36c18..ee77566ee7bcc6400838cb27f3d401fdd12727e1 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
@@ -297,12 +297,10 @@ class ClassEmitter extends CodeEmitterHelper {
if (backend.isNeededForReflection(classElement)) {
Link typeVars = classElement.typeVariables;
- List properties = [];
- for (TypeVariableType typeVar in typeVars) {
- properties.add(js.string(typeVar.name.slowToString()));
- properties.add(
- js.toExpression(
- task.metadataEmitter.reifyType(typeVar.element.bound)));
+ Iterable properties = [];
+ if (task.typeVariableHandler.typeVariablesOf(classElement) != null) {
+ properties = task.typeVariableHandler.typeVariablesOf(classElement)
+ .map(js.toExpression);
}
ClassElement superclass = classElement.superclass;
@@ -349,11 +347,15 @@ class ClassEmitter extends CodeEmitterHelper {
buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler));
String reflectionName = task.getReflectionName(classElement, className);
if (reflectionName != null) {
- List<int> interfaces = <int>[];
- for (DartType interface in classElement.interfaces) {
- interfaces.add(task.metadataEmitter.reifyType(interface));
+ if (!backend.isNeededForReflection(classElement)) {
+ buffer.write(',$n$n"+$reflectionName": 0');
+ } else {
+ List<int> interfaces = <int>[];
+ for (DartType interface in classElement.interfaces) {
+ interfaces.add(task.metadataEmitter.reifyType(interface));
+ }
+ buffer.write(',$n$n"+$reflectionName": $interfaces');
}
- buffer.write(',$n$n"+$reflectionName": $interfaces');
}
}

Powered by Google App Engine
This is Rietveld 408576698