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

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

Issue 23447003: Change reflective serialization rules to be able to take type literals (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « pkg/serialization/lib/serialization.dart ('k') | pkg/serialization/test/no_library_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/serialization/lib/src/mirrors_helpers.dart
diff --git a/pkg/serialization/lib/src/mirrors_helpers.dart b/pkg/serialization/lib/src/mirrors_helpers.dart
index 19360bfe22aa18ae9e498283aefebdde5b2e6d7b..fe211aa485b7d2082af6adea5071a459b3d12a32 100644
--- a/pkg/serialization/lib/src/mirrors_helpers.dart
+++ b/pkg/serialization/lib/src/mirrors_helpers.dart
@@ -82,8 +82,11 @@ Iterable<MethodMirror> publicGettersWithMatchingSetters(ClassMirror mirror) {
}
/**
- * A particularly bad case of polyfill, because we cannot yet use type names
- * as literals, so we have to be passed an instance and then extract a
- * ClassMirror from that. Given a horrible name as an extra reminder to fix it.
+ * Given either an instance or a type, returns the type. Instances of Type
+ * will be treated as types. Passing in an instance is really just backward
+ * compatibility.
*/
-ClassMirror turnInstanceIntoSomethingWeCanUse(x) => reflect(x).type;
+ClassMirror turnInstanceIntoSomethingWeCanUse(x) {
+ if (x is Type) return reflectClass(x);
+ return reflect(x).type;
+}
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | pkg/serialization/test/no_library_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698