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

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

Issue 23486007: Change the field and constructor parameter types of NoSuchMethodError to Symbol. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review 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
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 52aca10326e72eb235fd37debd112a095ab4aadf..8872d0973442937a4c28e82c19348e2c190a116e 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -243,7 +243,7 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
if (mirror == null) mirror = variables[fieldName];
if (mirror == null) {
// TODO(ahe): What receiver to use?
- throw new NoSuchMethodError(this, '${n(fieldName)}=', [arg], null);
+ throw new NoSuchMethodError(this, setterSymbol(fieldName), [arg], null);
}
mirror._setField(this, arg);
return reflect(arg);
@@ -253,7 +253,7 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
JsMirror mirror = members[fieldName];
if (mirror == null) {
// TODO(ahe): What receiver to use?
- throw new NoSuchMethodError(this, '${n(fieldName)}', [], null);
+ throw new NoSuchMethodError(this, fieldName, [], null);
}
return reflect(mirror._getField(this));
}
@@ -266,11 +266,9 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
}
JsDeclarationMirror mirror = members[memberName];
if (mirror == null) {
- // TODO(ahe): Pass namedArguments when NoSuchMethodError has been
- // fixed to use Symbol.
// TODO(ahe): What receiver to use?
throw new NoSuchMethodError(
- this, '${n(memberName)}', positionalArguments, null);
+ this, memberName, positionalArguments, namedArguments);
}
return reflect(mirror._invoke(positionalArguments, namedArguments));
}
@@ -385,6 +383,8 @@ Symbol s(String name) {
return new _symbol_dev.Symbol.unvalidated(name);
}
+Symbol setterSymbol(Symbol symbol) => s("${n(symbol)}=");
+
final JsMirrorSystem currentJsMirrorSystem = new JsMirrorSystem();
InstanceMirror reflect(Object reflectee) {
@@ -507,20 +507,19 @@ class JsMixinApplication extends JsTypeMirror with JsObjectMirror
Symbol memberName,
List positionalArguments,
[Map<Symbol,dynamic> namedArguments]) {
- // TODO(ahe): Pass namedArguments when NoSuchMethodError has
- // been fixed to use Symbol.
// TODO(ahe): What receiver to use?
- throw new NoSuchMethodError(this, n(memberName), positionalArguments, null);
+ throw new NoSuchMethodError(this, memberName,
+ positionalArguments, namedArguments);
}
InstanceMirror getField(Symbol fieldName) {
// TODO(ahe): What receiver to use?
- throw new NoSuchMethodError(this, n(fieldName), null, null);
+ throw new NoSuchMethodError(this, fieldName, null, null);
}
InstanceMirror setField(Symbol fieldName, Object arg) {
// TODO(ahe): What receiver to use?
- throw new NoSuchMethodError(this, '${n(fieldName)}=', [arg], null);
+ throw new NoSuchMethodError(this, setterSymbol(fieldName), [arg], null);
}
List<ClassMirror> get superinterfaces => [mixin];
@@ -889,7 +888,7 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
return reflect(arg);
}
// TODO(ahe): What receiver to use?
- throw new NoSuchMethodError(this, '${n(fieldName)}=', [arg], null);
+ throw new NoSuchMethodError(this, setterSymbol(fieldName), [arg], null);
}
InstanceMirror getField(Symbol fieldName) {
@@ -907,7 +906,7 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
}
}
// TODO(ahe): What receiver to use?
- throw new NoSuchMethodError(this, n(fieldName), null, null);
+ throw new NoSuchMethodError(this, fieldName, null, null);
}
InstanceMirror newInstance(Symbol constructorName,
@@ -922,11 +921,9 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
mirror = constructors.values.firstWhere(
(m) => m.constructorName == constructorName,
orElse: () {
- // TODO(ahe): Pass namedArguments when NoSuchMethodError has been
- // fixed to use Symbol.
// TODO(ahe): What receiver to use?
throw new NoSuchMethodError(
- owner, n(constructorName), positionalArguments, null);
+ owner, constructorName, positionalArguments, namedArguments);
});
JsCache.update(_jsConstructorCache, n(constructorName), mirror);
}
@@ -1004,11 +1001,9 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
}
JsMethodMirror mirror = methods[memberName];
if (mirror == null || !mirror.isStatic) {
- // TODO(ahe): Pass namedArguments when NoSuchMethodError has
- // been fixed to use Symbol.
// TODO(ahe): What receiver to use?
throw new NoSuchMethodError(
- this, n(memberName), positionalArguments, null);
+ this, memberName, positionalArguments, namedArguments);
}
return reflect(mirror._invoke(positionalArguments, namedArguments));
}
@@ -1123,7 +1118,7 @@ class JsVariableMirror extends JsDeclarationMirror implements VariableMirror {
void _setField(JsMirror receiver, Object arg) {
if (isFinal) {
- throw new NoSuchMethodError(this, '${n(simpleName)}=', [arg], null);
+ throw new NoSuchMethodError(this, setterSymbol(simpleName), [arg], null);
}
receiver._storeField(_jsName, arg);
}
@@ -1298,11 +1293,9 @@ class JsMethodMirror extends JsDeclarationMirror implements MethodMirror {
throw new RuntimeError('Cannot invoke instance method without receiver.');
}
if (_parameterCount != positionalArguments.length || _jsFunction == null) {
- // TODO(ahe): Pass namedArguments when NoSuchMethodError has
- // been fixed to use Symbol.
// TODO(ahe): What receiver to use?
throw new NoSuchMethodError(
- owner, n(simpleName), positionalArguments, null);
+ owner, simpleName, positionalArguments, namedArguments);
}
return JS('', r'#.apply(#, #)', _jsFunction, JS_CURRENT_ISOLATE(),
new List.from(positionalArguments));
@@ -1321,7 +1314,7 @@ class JsMethodMirror extends JsDeclarationMirror implements MethodMirror {
if (isSetter) {
return _invoke([arg], null);
} else {
- throw new NoSuchMethodError(this, '${n(simpleName)}=', [], null);
+ throw new NoSuchMethodError(this, setterSymbol(simpleName), [], null);
}
}

Powered by Google App Engine
This is Rietveld 408576698