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

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

Issue 23045004: Throw when reflecting on elements not covered by a `MirrorsUsed` annotation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Nicolas' comments. Created 7 years, 4 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/compiler/implementation/mirrors_used.dart ('k') | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_helper.dart
diff --git a/sdk/lib/_internal/lib/js_helper.dart b/sdk/lib/_internal/lib/js_helper.dart
index db8cb3730459b3da82d8e16b751eba7c3c5c2906..8ce6432802113406f509c2997a9b3870af1f2d45 100644
--- a/sdk/lib/_internal/lib/js_helper.dart
+++ b/sdk/lib/_internal/lib/js_helper.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -86,6 +86,11 @@ createUnmangledInvocationMirror(Symbol symbol, internalName, kind, arguments,
argumentNames);
}
+void throwInvalidReflectionError(Symbol memberName) {
+ throw new UnsupportedError('invalid reflective use of ${memberName}, '
+ 'which is not included by a @MirrorsUsed annotation');
+}
+
class JSInvocationMirror implements Invocation {
static const METHOD = 0;
static const GETTER = 1;
@@ -99,7 +104,7 @@ class JSInvocationMirror implements Invocation {
final List _arguments;
final List _namedArgumentNames;
/** Map from argument name to index in _arguments. */
- Map<String,dynamic> _namedIndices = null;
+ Map<String, dynamic> _namedIndices = null;
JSInvocationMirror(this._memberName,
this._internalName,
@@ -135,7 +140,7 @@ class JSInvocationMirror implements Invocation {
return makeLiteralListConst(list);
}
- Map<Symbol,dynamic> get namedArguments {
+ Map<Symbol, dynamic> get namedArguments {
// TODO: Make maps const (issue 10471)
if (isAccessor) return <Symbol, dynamic>{};
int namedArgumentCount = _namedArgumentNames.length;
@@ -170,6 +175,9 @@ class JSInvocationMirror implements Invocation {
}
var method = JS('var', '#[#]', receiver, name);
if (JS('String', 'typeof #', method) == 'function') {
+ if (JS('bool', '#[#] == false', method, JS_GET_NAME("REFLECTABLE"))) {
+ throwInvalidReflectionError(memberName);
+ }
return new CachedInvocation(method, isIntercepted, interceptor);
} else {
// In this case, receiver doesn't implement name. So we should
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/mirrors_used.dart ('k') | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698