| Index: lib/src/codegen/js_codegen.dart
|
| diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
|
| index 88215c42ea58829381a016fc23d2cd62657d85fc..2b3fddff52f27b3870c7802ab85220cabf934bfb 100644
|
| --- a/lib/src/codegen/js_codegen.dart
|
| +++ b/lib/src/codegen/js_codegen.dart
|
| @@ -379,10 +379,11 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
|
| }
|
| }
|
|
|
| - var classDecl = new JS.ClassDeclaration(new JS.ClassExpression(
|
| - new JS.Identifier(element.name), _classHeritage(element), body));
|
| + var classExpr = new JS.ClassExpression(
|
| + new JS.Identifier(element.name), _classHeritage(element), body);
|
|
|
| - return _finishClassDef(element.type, classDecl);
|
| + return _finishClassDef(
|
| + element.type, _emitClassHeritageWorkaround(classExpr));
|
| }
|
|
|
| JS.Statement _emitJsType(String dartClassName, DartObject jsName) {
|
| @@ -674,6 +675,27 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
|
| }
|
| }
|
|
|
| + _isQualifiedPath(JS.Expression node) =>
|
| + node is JS.Identifier ||
|
| + node is JS.PropertyAccess &&
|
| + _isQualifiedPath(node.receiver) &&
|
| + node.selector is JS.LiteralString;
|
| +
|
| + /// Workaround for Closure: super classes must be qualified paths.
|
| + JS.Statement _emitClassHeritageWorkaround(JS.ClassExpression cls) {
|
| + if (options.closure &&
|
| + cls.heritage != null &&
|
| + !_isQualifiedPath(cls.heritage)) {
|
| + var superVar = new JS.TemporaryId(cls.name.name + r'$super');
|
| + return _statement([
|
| + js.statement('const # = #;', [superVar, cls.heritage]),
|
| + new JS.ClassDeclaration(
|
| + new JS.ClassExpression(cls.name, superVar, cls.methods))
|
| + ]);
|
| + }
|
| + return new JS.ClassDeclaration(cls);
|
| + }
|
| +
|
| /// Emit class members that need to come after the class declaration, such
|
| /// as static fields. See [_emitClassMethods] for things that are emitted
|
| /// inside the ES6 `class { ... }` node.
|
| @@ -702,7 +724,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
|
| }
|
| }
|
|
|
| - body.add(new JS.ClassDeclaration(cls));
|
| + body.add(_emitClassHeritageWorkaround(cls));
|
|
|
| // TODO(jmesserly): we should really just extend native Array.
|
| if (jsPeerName != null && classElem.typeParameters.isNotEmpty) {
|
|
|