| Index: lib/src/compiler/code_generator.dart
|
| diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart
|
| index 23e36750e5d2f921c9d29526d888b309ccd2db0f..d07bfb06619611d3aa7cb7238e7f19185343f0e9 100644
|
| --- a/lib/src/compiler/code_generator.dart
|
| +++ b/lib/src/compiler/code_generator.dart
|
| @@ -598,6 +598,9 @@ class CodeGenerator extends GeneralizingAstVisitor
|
| JS.Statement visitClassDeclaration(ClassDeclaration node) {
|
| var classElem = node.element;
|
|
|
| + // If this class is annotated with `@JS`, then there is nothing to emit.
|
| + if (findAnnotation(classElem, isPublicJSAnnotation) != null) return null;
|
| +
|
| // If this is a JavaScript type, emit it now and then exit.
|
| var jsTypeDef = _emitJsType(classElem);
|
| if (jsTypeDef != null) return jsTypeDef;
|
| @@ -3020,6 +3023,12 @@ class CodeGenerator extends GeneralizingAstVisitor
|
|
|
| JS.Expression _emitConstructorName(
|
| ConstructorElement element, DartType type, SimpleIdentifier name) {
|
| + var classElem = element.enclosingElement;
|
| + if (findAnnotation(classElem, isPublicJSAnnotation) != null) {
|
| + var annotationName = getAnnotationName(classElem, isPublicJSAnnotation);
|
| + var typeName = js.string(annotationName ?? classElem.name);
|
| + return new JS.PropertyAccess(new JS.Identifier('self'), typeName);
|
| + }
|
| var typeName = _emitType(type);
|
| if (name != null || element.isFactory) {
|
| var namedCtor = _constructorName(element);
|
| @@ -3057,10 +3066,27 @@ class CodeGenerator extends GeneralizingAstVisitor
|
| var args = _visit(argumentList) as List<JS.Expression>;
|
| return isFactory ? new JS.Call(ctor, args) : new JS.New(ctor, args);
|
| }
|
| + if (_isObjectLiteral(element.enclosingElement)) {
|
| + return _emitObjectLiteral(argumentList);
|
| + }
|
| if (isConst) return _emitConst(emitNew);
|
| return emitNew();
|
| }
|
|
|
| + bool _isObjectLiteral(ClassElement classElem) {
|
| + return findAnnotation(classElem, isPublicJSAnnotation) != null &&
|
| + findAnnotation(classElem, isJSAnonymousAnnotation) != null;
|
| + }
|
| +
|
| + JS.Expression _emitObjectLiteral(ArgumentList argumentList) {
|
| + var args = _visit(argumentList) as List<JS.Expression>;
|
| + if (args.isEmpty) {
|
| + return js.call('{}');
|
| + }
|
| + assert(args.single is JS.ObjectInitializer);
|
| + return args.single;
|
| + }
|
| +
|
| @override
|
| visitInstanceCreationExpression(InstanceCreationExpression node) {
|
| var element = node.staticElement;
|
|
|