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

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

Issue 15906010: Expose default constructors through ClassElement.localMembers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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: dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
index db8d87ff9cf09d0e2658e562c1dda3c2fe7fd558..ef0b2dd3f152ec012f403fc41cf9ec1e46dab3e8 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
@@ -392,15 +392,24 @@ class JsClassMirror extends JsObjectMirror implements ClassMirror {
InstanceMirror newInstance(Symbol constructorName,
List positionalArguments,
- [Map<Symbol,dynamic> namedArguments]) {
+ [Map<Symbol, dynamic> namedArguments]) {
if (namedArguments != null && !namedArguments.isEmpty) {
throw new UnsupportedError('Named arguments are not implemented');
}
- String constructorName = '${n(simpleName)}\$${n(constructorName)}';
- return reflect(JS('', r'#[#].apply(#, #)', JS_CURRENT_ISOLATE(),
- constructorName,
- JS_CURRENT_ISOLATE(),
- new List.from(positionalArguments)));
+ String mangledName = '${n(simpleName)}\$${n(constructorName)}';
+ var factory = JS('', '#[#]', JS_CURRENT_ISOLATE(), mangledName);
+ if (factory == null) {
+ // TODO(ahe): Pass namedArguments when NoSuchMethodError has
+ // been fixed to use Symbol.
+ // TODO(ahe): What receiver to use?
+ throw new NoSuchMethodError(
+ this, "constructor ${n(constructorName)}", positionalArguments,
+ null);
+ }
+ return reflect(JS('', r'#.apply(#, #)',
+ factory,
+ JS_CURRENT_ISOLATE(),
+ new List.from(positionalArguments)));
}
Future<InstanceMirror> newInstanceAsync(

Powered by Google App Engine
This is Rietveld 408576698