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

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart

Issue 2415053004: Some mirrors fixes (Closed)
Patch Set: Minor fixes Created 4 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
« no previous file with comments | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | pkg/dev_compiler/tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart b/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart
index f87c4c9d41d72ab0459ebd47ec4da36559ae6be5..151affbd2e74579409b971e17267776afe50426a 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart
@@ -281,7 +281,12 @@ class JsClassMirror extends JsMirror implements ClassMirror {
List<InstanceMirror> get metadata {
if (_metadata == null) {
// Load metadata.
- var fn = JS('Function', '#[dart.metadata]', _unwrap(_cls));
+ var unwrapped = _unwrap(_cls);
+ // Only get metadata directly embedded on this class, not its
+ // superclasses.
+ var fn = JS('Function',
+ 'Object.hasOwnProperty.call(#, dart.metadata) ? #[dart.metadata] : null',
+ unwrapped, unwrapped);
_metadata = (fn == null)
? const <InstanceMirror>[]
: new List<InstanceMirror>.unmodifiable(
@@ -520,7 +525,9 @@ class JsMethodMirror extends JsMirror implements MethodMirror {
_metadata = const [];
return;
}
- if (ftype is List) {
+
+ // TODO(vsm): Why does generic function type trigger true for List?
+ if (ftype is! Function && ftype is List) {
// Record metadata
_metadata = new List<InstanceMirror>.unmodifiable(
ftype.skip(1).map((a) => reflect(a)));
@@ -529,6 +536,14 @@ class JsMethodMirror extends JsMirror implements MethodMirror {
_metadata = const [];
}
+ // TODO(vsm): Handle generic function types properly. Or deprecate mirrors
+ // before we need to!
+ if (JS('bool', 'typeof(#) == "function"', ftype)) {
+ // Instantiate the generic version.
+ // TODO(vsm): Can't use arguments.length on arrow function.
+ ftype = JS('', '#.apply(null, #)', ftype, [dynamic, dynamic, dynamic]);
+ }
+
// TODO(vsm): Add named args.
List args = ftype.args;
List opts = ftype.optionals;
« no previous file with comments | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | pkg/dev_compiler/tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698