| Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| index 1b306a74106e06b1567709c1048fa146950435f5..456e8e345c5fae122d444cf393ace275029f5095 100644
|
| --- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| +++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| @@ -3872,6 +3872,7 @@ class CodeGenerator extends GeneralizingAstVisitor
|
| JS.Expression emitNew() {
|
| JS.Expression ctor;
|
| bool isFactory = false;
|
| + bool isNative = false;
|
| if (element == null) {
|
| // TODO(jmesserly): this only happens if we had a static error.
|
| // Should we generate a throw instead?
|
| @@ -3884,9 +3885,12 @@ class CodeGenerator extends GeneralizingAstVisitor
|
| } else {
|
| ctor = _emitConstructorName(element, type, name);
|
| isFactory = element.isFactory;
|
| + var classElem = element.enclosingElement;
|
| + isNative = _isJSNative(classElem);
|
| }
|
| var args = _visit(argumentList) as List<JS.Expression>;
|
| - return isFactory ? new JS.Call(ctor, args) : new JS.New(ctor, args);
|
| + // Native factory constructors are JS constructors - use new here.
|
| + return isFactory && !isNative ? new JS.Call(ctor, args) : new JS.New(ctor, args);
|
| }
|
|
|
| if (element != null && _isObjectLiteral(element.enclosingElement)) {
|
| @@ -3901,6 +3905,9 @@ class CodeGenerator extends GeneralizingAstVisitor
|
| findAnnotation(classElem, isJSAnonymousAnnotation) != null;
|
| }
|
|
|
| + bool _isJSNative(ClassElement classElem) =>
|
| + findAnnotation(classElem, isPublicJSAnnotation) != null;
|
| +
|
| JS.Expression _emitObjectLiteral(ArgumentList argumentList) {
|
| var args = _visit(argumentList) as List<JS.Expression>;
|
| if (args.isEmpty) {
|
|
|