| Index: sdk/lib/_internal/lib/js_mirrors.dart
|
| diff --git a/sdk/lib/_internal/lib/js_mirrors.dart b/sdk/lib/_internal/lib/js_mirrors.dart
|
| index fdf7393699479f76066cc22426c3694580373ece..dca0d98dfd5bcef5bf399449ef51b0086bfdc0cf 100644
|
| --- a/sdk/lib/_internal/lib/js_mirrors.dart
|
| +++ b/sdk/lib/_internal/lib/js_mirrors.dart
|
| @@ -22,6 +22,7 @@ import 'dart:_internal' as _symbol_dev;
|
|
|
| import 'dart:_js_helper' show
|
| BoundClosure,
|
| + CachedInvocation,
|
| Closure,
|
| JSInvocationMirror,
|
| JsCache,
|
| @@ -29,6 +30,7 @@ import 'dart:_js_helper' show
|
| Primitives,
|
| ReflectionInfo,
|
| RuntimeError,
|
| + TearOffClosure,
|
| TypeVariable,
|
| UnimplementedNoSuchMethodError,
|
| createRuntimeType,
|
| @@ -36,7 +38,6 @@ import 'dart:_js_helper' show
|
| getMangledTypeName,
|
| getMetadata,
|
| getRuntimeType,
|
| - hasReflectableProperty,
|
| runtimeTypeToString,
|
| setRuntimeTypeInfo,
|
| throwInvalidReflectionError;
|
| @@ -51,6 +52,10 @@ import 'dart:_js_names';
|
|
|
| const String METHODS_WITH_OPTIONAL_ARGUMENTS = r'$methodsWithOptionalArguments';
|
|
|
| +bool hasReflectableProperty(var jsFunction) {
|
| + return JS('bool', '# in #', JS_GET_NAME("REFLECTABLE"), jsFunction);
|
| +}
|
| +
|
| /// No-op method that is called to inform the compiler that tree-shaking needs
|
| /// to be disabled.
|
| disableTreeShaking() => preserveNames();
|
| @@ -941,6 +946,13 @@ class JsInstanceMirror extends JsObjectMirror implements InstanceMirror {
|
| return cacheEntry;
|
| }
|
|
|
| + bool _isReflectable(CachedInvocation cachedInvocation) {
|
| + // TODO(floitsch): tear-off closure does not guarantee that the
|
| + // function is reflectable.
|
| + var method = cachedInvocation.jsFunction;
|
| + return hasReflectableProperty(method) || reflectee is TearOffClosure;
|
| + }
|
| +
|
| /// Invoke the member specified through name and type on the reflectee.
|
| /// As a side-effect, this populates the class-specific invocation cache
|
| /// for the reflectee.
|
| @@ -959,7 +971,7 @@ class JsInstanceMirror extends JsObjectMirror implements InstanceMirror {
|
| var cacheEntry = _getCachedInvocation(
|
| name, type, reflectiveName, positionalArguments, namedArguments);
|
|
|
| - if (cacheEntry.isNoSuchMethod) {
|
| + if (cacheEntry.isNoSuchMethod || !_isReflectable(cacheEntry)) {
|
| // Could be that we want to invoke a getter, or get a method.
|
| if (type == JSInvocationMirror.METHOD && _instanceFieldExists(name)) {
|
| return getField(name).invoke(
|
| @@ -971,6 +983,11 @@ class JsInstanceMirror extends JsObjectMirror implements InstanceMirror {
|
| name = s("${n(name)}=");
|
| }
|
|
|
| + if (!cacheEntry.isNoSuchMethod) {
|
| + // Not reflectable.
|
| + throwInvalidReflectionError(reflectiveName);
|
| + }
|
| +
|
| String mangledName = reflectiveNames[reflectiveName];
|
| // TODO(ahe): Get the argument names.
|
| List<String> argumentNames = [];
|
|
|