Some mirrors fixes

R=leafp@google.com

Review URL: https://codereview.chromium.org/2415053004 .
This commit is contained in:
Vijay Menon 2016-10-14 12:19:24 -07:00
parent 0d99435f0c
commit 852ef37f71
6 changed files with 46 additions and 11 deletions

View file

@ -144,6 +144,7 @@ define([], function() {
let ListOfClassMirror = () => (ListOfClassMirror = dart.constFn(core.List$(mirrors.ClassMirror)))();
let ListOfTypeVariableMirror = () => (ListOfTypeVariableMirror = dart.constFn(core.List$(mirrors.TypeVariableMirror)))();
let MapOfSymbol$MethodMirror = () => (MapOfSymbol$MethodMirror = dart.constFn(core.Map$(core.Symbol, mirrors.MethodMirror)))();
let JSArrayOfType = () => (JSArrayOfType = dart.constFn(_interceptors.JSArray$(core.Type)))();
let ListOfParameterMirror = () => (ListOfParameterMirror = dart.constFn(core.List$(mirrors.ParameterMirror)))();
let ListOfFloat32x4 = () => (ListOfFloat32x4 = dart.constFn(core.List$(typed_data.Float32x4)))();
let ListOfInt32x4 = () => (ListOfInt32x4 = dart.constFn(core.List$(typed_data.Int32x4)))();
@ -13376,7 +13377,8 @@ define([], function() {
_js_mirrors.JsClassMirror = class JsClassMirror extends _js_mirrors.JsMirror {
get metadata() {
if (this[_metadata$] == null) {
let fn = _js_mirrors._unwrap(this[_cls])[dart.metadata];
let unwrapped = _js_mirrors._unwrap(this[_cls]);
let fn = Object.hasOwnProperty.call(unwrapped, dart.metadata) ? unwrapped[dart.metadata] : null;
this[_metadata$] = fn == null ? const$0 || (const$0 = dart.constList([], mirrors.InstanceMirror)) : ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dcall(fn), 'map', dart.fn(i => _js_mirrors.reflect(i), dynamicToInstanceMirror()))));
}
return this[_metadata$];
@ -13744,12 +13746,15 @@ define([], function() {
this[_metadata$] = const$3 || (const$3 = dart.constList([], mirrors.InstanceMirror));
return;
}
if (core.List.is(ftype)) {
if (!core.Function.is(ftype) && core.List.is(ftype)) {
this[_metadata$] = ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dsend(ftype, 'skip', 1), 'map', dart.fn(a => _js_mirrors.reflect(a), dynamicToInstanceMirror()))));
ftype = dart.dindex(ftype, 0);
} else {
this[_metadata$] = const$4 || (const$4 = dart.constList([], mirrors.InstanceMirror));
}
if (typeof ftype == "function") {
ftype = ftype.apply(null, JSArrayOfType().of([dart.dynamic, dart.dynamic, dart.dynamic]));
}
let args = core.List._check(dart.dload(ftype, 'args'));
let opts = core.List._check(dart.dload(ftype, 'optionals'));
let params = ListOfParameterMirror().new(dart.notNull(args[dartx.length]) + dart.notNull(opts[dartx.length]));

View file

@ -144,6 +144,7 @@
let ListOfClassMirror = () => (ListOfClassMirror = dart.constFn(core.List$(mirrors.ClassMirror)))();
let ListOfTypeVariableMirror = () => (ListOfTypeVariableMirror = dart.constFn(core.List$(mirrors.TypeVariableMirror)))();
let MapOfSymbol$MethodMirror = () => (MapOfSymbol$MethodMirror = dart.constFn(core.Map$(core.Symbol, mirrors.MethodMirror)))();
let JSArrayOfType = () => (JSArrayOfType = dart.constFn(_interceptors.JSArray$(core.Type)))();
let ListOfParameterMirror = () => (ListOfParameterMirror = dart.constFn(core.List$(mirrors.ParameterMirror)))();
let ListOfFloat32x4 = () => (ListOfFloat32x4 = dart.constFn(core.List$(typed_data.Float32x4)))();
let ListOfInt32x4 = () => (ListOfInt32x4 = dart.constFn(core.List$(typed_data.Int32x4)))();
@ -13376,7 +13377,8 @@
_js_mirrors.JsClassMirror = class JsClassMirror extends _js_mirrors.JsMirror {
get metadata() {
if (this[_metadata$] == null) {
let fn = _js_mirrors._unwrap(this[_cls])[dart.metadata];
let unwrapped = _js_mirrors._unwrap(this[_cls]);
let fn = Object.hasOwnProperty.call(unwrapped, dart.metadata) ? unwrapped[dart.metadata] : null;
this[_metadata$] = fn == null ? const$0 || (const$0 = dart.constList([], mirrors.InstanceMirror)) : ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dcall(fn), 'map', dart.fn(i => _js_mirrors.reflect(i), dynamicToInstanceMirror()))));
}
return this[_metadata$];
@ -13744,12 +13746,15 @@
this[_metadata$] = const$3 || (const$3 = dart.constList([], mirrors.InstanceMirror));
return;
}
if (core.List.is(ftype)) {
if (!core.Function.is(ftype) && core.List.is(ftype)) {
this[_metadata$] = ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dsend(ftype, 'skip', 1), 'map', dart.fn(a => _js_mirrors.reflect(a), dynamicToInstanceMirror()))));
ftype = dart.dindex(ftype, 0);
} else {
this[_metadata$] = const$4 || (const$4 = dart.constList([], mirrors.InstanceMirror));
}
if (typeof ftype == "function") {
ftype = ftype.apply(null, JSArrayOfType().of([dart.dynamic, dart.dynamic, dart.dynamic]));
}
let args = core.List._check(dart.dload(ftype, 'args'));
let opts = core.List._check(dart.dload(ftype, 'optionals'));
let params = ListOfParameterMirror().new(dart.notNull(args[dartx.length]) + dart.notNull(opts[dartx.length]));

View file

@ -142,6 +142,7 @@ let JSArrayOfClassMirror = () => (JSArrayOfClassMirror = dart.constFn(_intercept
let ListOfClassMirror = () => (ListOfClassMirror = dart.constFn(core.List$(mirrors.ClassMirror)))();
let ListOfTypeVariableMirror = () => (ListOfTypeVariableMirror = dart.constFn(core.List$(mirrors.TypeVariableMirror)))();
let MapOfSymbol$MethodMirror = () => (MapOfSymbol$MethodMirror = dart.constFn(core.Map$(core.Symbol, mirrors.MethodMirror)))();
let JSArrayOfType = () => (JSArrayOfType = dart.constFn(_interceptors.JSArray$(core.Type)))();
let ListOfParameterMirror = () => (ListOfParameterMirror = dart.constFn(core.List$(mirrors.ParameterMirror)))();
let ListOfFloat32x4 = () => (ListOfFloat32x4 = dart.constFn(core.List$(typed_data.Float32x4)))();
let ListOfInt32x4 = () => (ListOfInt32x4 = dart.constFn(core.List$(typed_data.Int32x4)))();
@ -13374,7 +13375,8 @@ let const;
_js_mirrors.JsClassMirror = class JsClassMirror extends _js_mirrors.JsMirror {
get metadata() {
if (this[_metadata] == null) {
let fn = _js_mirrors._unwrap(this[_cls])[dart.metadata];
let unwrapped = _js_mirrors._unwrap(this[_cls]);
let fn = Object.hasOwnProperty.call(unwrapped, dart.metadata) ? unwrapped[dart.metadata] : null;
this[_metadata] = fn == null ? const || (const = dart.constList([], mirrors.InstanceMirror)) : ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dcall(fn), 'map', dart.fn(i => _js_mirrors.reflect(i), dynamicToInstanceMirror()))));
}
return this[_metadata];
@ -13742,12 +13744,15 @@ _js_mirrors.JsMethodMirror = class JsMethodMirror extends _js_mirrors.JsMirror {
this[_metadata] = const || (const = dart.constList([], mirrors.InstanceMirror));
return;
}
if (core.List.is(ftype)) {
if (!core.Function.is(ftype) && core.List.is(ftype)) {
this[_metadata] = ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dsend(ftype, 'skip', 1), 'map', dart.fn(a => _js_mirrors.reflect(a), dynamicToInstanceMirror()))));
ftype = dart.dindex(ftype, 0);
} else {
this[_metadata] = const || (const = dart.constList([], mirrors.InstanceMirror));
}
if (typeof ftype == "function") {
ftype = ftype.apply(null, JSArrayOfType().of([dart.dynamic, dart.dynamic, dart.dynamic]));
}
let args = core.List._check(dart.dload(ftype, 'args'));
let opts = core.List._check(dart.dload(ftype, 'optionals'));
let params = ListOfParameterMirror().new(dart.notNull(args[dartx.length]) + dart.notNull(opts[dartx.length]));

View file

@ -145,6 +145,7 @@ dart_library.library('dart_sdk', null, /* Imports */[
let ListOfClassMirror = () => (ListOfClassMirror = dart.constFn(core.List$(mirrors.ClassMirror)))();
let ListOfTypeVariableMirror = () => (ListOfTypeVariableMirror = dart.constFn(core.List$(mirrors.TypeVariableMirror)))();
let MapOfSymbol$MethodMirror = () => (MapOfSymbol$MethodMirror = dart.constFn(core.Map$(core.Symbol, mirrors.MethodMirror)))();
let JSArrayOfType = () => (JSArrayOfType = dart.constFn(_interceptors.JSArray$(core.Type)))();
let ListOfParameterMirror = () => (ListOfParameterMirror = dart.constFn(core.List$(mirrors.ParameterMirror)))();
let ListOfFloat32x4 = () => (ListOfFloat32x4 = dart.constFn(core.List$(typed_data.Float32x4)))();
let ListOfInt32x4 = () => (ListOfInt32x4 = dart.constFn(core.List$(typed_data.Int32x4)))();
@ -13377,7 +13378,8 @@ dart_library.library('dart_sdk', null, /* Imports */[
_js_mirrors.JsClassMirror = class JsClassMirror extends _js_mirrors.JsMirror {
get metadata() {
if (this[_metadata$] == null) {
let fn = _js_mirrors._unwrap(this[_cls])[dart.metadata];
let unwrapped = _js_mirrors._unwrap(this[_cls]);
let fn = Object.hasOwnProperty.call(unwrapped, dart.metadata) ? unwrapped[dart.metadata] : null;
this[_metadata$] = fn == null ? const$0 || (const$0 = dart.constList([], mirrors.InstanceMirror)) : ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dcall(fn), 'map', dart.fn(i => _js_mirrors.reflect(i), dynamicToInstanceMirror()))));
}
return this[_metadata$];
@ -13745,12 +13747,15 @@ dart_library.library('dart_sdk', null, /* Imports */[
this[_metadata$] = const$3 || (const$3 = dart.constList([], mirrors.InstanceMirror));
return;
}
if (core.List.is(ftype)) {
if (!core.Function.is(ftype) && core.List.is(ftype)) {
this[_metadata$] = ListOfInstanceMirror().unmodifiable(core.Iterable._check(dart.dsend(dart.dsend(ftype, 'skip', 1), 'map', dart.fn(a => _js_mirrors.reflect(a), dynamicToInstanceMirror()))));
ftype = dart.dindex(ftype, 0);
} else {
this[_metadata$] = const$4 || (const$4 = dart.constList([], mirrors.InstanceMirror));
}
if (typeof ftype == "function") {
ftype = ftype.apply(null, JSArrayOfType().of([dart.dynamic, dart.dynamic, dart.dynamic]));
}
let args = core.List._check(dart.dload(ftype, 'args'));
let opts = core.List._check(dart.dload(ftype, 'optionals'));
let params = ListOfParameterMirror().new(dart.notNull(args[dartx.length]) + dart.notNull(opts[dartx.length]));

View file

@ -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;

View file

@ -24,7 +24,7 @@
[warning] Unsound implicit cast from dynamic to E (dart:_interceptors/js_array.dart, line 564, col 12)
[warning] Unsound implicit cast from dynamic to JSArray<String> (dart:_js_helper, line 79, col 37)
[warning] Unsound implicit cast from dynamic to E (dart:_js_helper, line 882, col 16)
[warning] Unsound implicit cast from dynamic to () → List<Type> (dart:_js_mirrors, line 417, col 40)
[warning] Unsound implicit cast from dynamic to () → List<Type> (dart:_js_mirrors, line 422, col 40)
[warning] Unsound implicit cast from dynamic to List<String> (dart:_interceptors/js_string.dart, line 92, col 14)
[warning] Unsound implicit cast from dynamic to List<String> (dart:_interceptors/js_string.dart, line 95, col 14)
[warning] Unsound implicit cast from dynamic to LinkedHashMapCell<K, V> (dart:_js_helper/linked_hash_map.dart, line 119, col 40)