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

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

Issue 14773027: Fix regression in meta-serializing rules (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Slight improvement for the case of duplicate library names Created 7 years, 7 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/serialization_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/serialization/lib/src/serialization_rule.dart
diff --git a/pkg/serialization/lib/src/serialization_rule.dart b/pkg/serialization/lib/src/serialization_rule.dart
index 1a592a7eb8411351d6c402349a772e2393d8f383..9d7401259a714fc7567e3d4cfdc854d25123f915 100644
--- a/pkg/serialization/lib/src/serialization_rule.dart
+++ b/pkg/serialization/lib/src/serialization_rule.dart
@@ -400,12 +400,25 @@ class MirrorRule extends NamedObjectRule {
var lookupFull = r.objectNamed(qualifiedName, (x) => null);
if (lookupFull != null) return lookupFull;
var separatorIndex = qualifiedName.lastIndexOf(".");
- var lib = new Symbol(qualifiedName.substring(0, separatorIndex));
var type = qualifiedName.substring(separatorIndex + 1);
var lookup = r.objectNamed(type, (x) => null);
if (lookup != null) return lookup;
- var libMirror = currentMirrorSystem().findLibrary(lib).first;
- return libMirror.classes[new Symbol(type)];
+ var name = qualifiedName.substring(0, separatorIndex);
+ // This is very ugly. The library name for an unnamed library is its URI.
+ // That can't be constructed as a Symbol, so we can't use findLibrary.
+ // So follow one or the other path depending if it has a colon, which we
+ // assume is in any URI and can't be in a Symbol.
+ if (name.contains(":")) {
+ var uri = new Uri(name);
+ var libMirror = currentMirrorSystem().libraries[uri];
+ return libMirror.classes[new Symbol(type)];
+ } else {
+ var symbol = new Symbol(name);
+ var typeSymbol = new Symbol(type);
+ var libMirror = currentMirrorSystem().findLibrary(symbol).firstWhere(
+ (lib) => lib.classes[typeSymbol] != null);
+ return libMirror.classes[typeSymbol];
+ }
}
}
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | pkg/serialization/test/serialization_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698