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

Unified Diff: sdk/lib/_internal/lib/js_mirrors.dart

Issue 294293003: Allow delegate calls even though the target is not reflectable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: TearoffClosure is superclass of BoundClosure. Created 6 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 | « sdk/lib/_internal/lib/js_helper.dart ('k') | tests/compiler/dart2js_extra/inference_nsm_mirrors_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = [];
« no previous file with comments | « sdk/lib/_internal/lib/js_helper.dart ('k') | tests/compiler/dart2js_extra/inference_nsm_mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698