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

Unified Diff: dart/pkg/serialization/lib/src/mirrors_helpers.dart

Issue 16645002: Preliminary support for reflecting on generic types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/serialization/lib/src/mirrors_helpers.dart
diff --git a/dart/pkg/serialization/lib/src/mirrors_helpers.dart b/dart/pkg/serialization/lib/src/mirrors_helpers.dart
index 4058514a18d4992d586e78a8e36db04af57dba52..19360bfe22aa18ae9e498283aefebdde5b2e6d7b 100644
--- a/dart/pkg/serialization/lib/src/mirrors_helpers.dart
+++ b/dart/pkg/serialization/lib/src/mirrors_helpers.dart
@@ -13,6 +13,14 @@ import 'dart:mirrors';
export 'dart:mirrors';
import 'serialization_helpers.dart';
+// TODO(alanknight): Remove this method. It is working around a bug
+// in the Dart VM which incorrectly returns Object as the superclass
+// of Object.
+_getSuperclass(ClassMirror mirror) {
ahe 2013/06/10 13:17:26 I've decided to drop the changes to pkg/serializat
+ var superclass = mirror.superclass;
+ return (superclass == mirror) ? null : superclass;
+}
+
/**
* Return a list of all the public fields of a class, including inherited
* fields.
@@ -20,9 +28,9 @@ import 'serialization_helpers.dart';
Iterable<VariableMirror> publicFields(ClassMirror mirror) {
var mine = mirror.variables.values.where(
(x) => !(x.isPrivate || x.isStatic));
- var mySuperclass = mirror.superclass;
- if (mySuperclass != mirror) {
- return append(publicFields(mirror.superclass), mine);
+ var mySuperclass = _getSuperclass(mirror);
+ if (mySuperclass != null) {
+ return append(publicFields(mySuperclass), mine);
} else {
return mine;
}
@@ -34,8 +42,8 @@ bool hasField(Symbol name, ClassMirror mirror) {
if (name == null) return false;
var field = mirror.variables[name];
if (field != null && !field.isStatic) return true;
- var superclass = mirror.superclass;
- if (superclass == mirror) return false;
+ var superclass = _getSuperclass(mirror);
+ if (superclass == null) return false;
return hasField(name, superclass);
}
@@ -45,9 +53,9 @@ bool hasField(Symbol name, ClassMirror mirror) {
*/
Iterable<MethodMirror> publicGetters(ClassMirror mirror) {
var mine = mirror.getters.values.where((x) => !(x.isPrivate || x.isStatic));
- var mySuperclass = mirror.superclass;
- if (mySuperclass != mirror) {
- return append(publicGetters(mirror.superclass), mine);
+ var mySuperclass = _getSuperclass(mirror);
+ if (mySuperclass != null) {
+ return append(publicGetters(mySuperclass), mine);
} else {
return mine.toList();
}
@@ -58,8 +66,8 @@ bool hasGetter(Symbol name, ClassMirror mirror) {
if (name == null) return false;
var getter = mirror.getters[name];
if (getter != null && !getter.isStatic) return true;
- var superclass = mirror.superclass;
- if (superclass == mirror) return false;
+ var superclass = _getSuperclass(mirror);
+ if (superclass == null) return false;
return hasField(name, superclass);
}
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698