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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1193083002: fixes #231, mixin application (aka ClassTypeAlias) implicit ctors (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 55731d2e74ff4fb5290e6dd956894c5a4d9ceea8..b3421f5e96af27cb25572df60a51cdd3a7c9a255 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -310,7 +310,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
@override
visitFunctionTypeAlias(FunctionTypeAlias node) {
- // If we've already emitted this class, skip it.
var element = node.element;
var type = element.type;
var name = element.name;
@@ -329,11 +328,25 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
@override
JS.Statement visitClassTypeAlias(ClassTypeAlias node) {
- // If we've already emitted this class, skip it.
var element = node.element;
+ // Forward all generative constructors from the base class.
+ var body = [];
+
+ var supertype = element.supertype;
+ if (!supertype.isObject) {
+ for (var ctor in element.constructors) {
+ var parentCtor = supertype.lookUpConstructor(ctor.name, ctor.library);
+ var fun = js.call('function() { super.#(...#); }', [
+ _constructorName(parentCtor),
+ new JS.Identifier('arguments', allowRename: false)
+ ]);
+ body.add(new JS.Method(_constructorName(ctor), fun));
+ }
+ }
+
var classDecl = new JS.ClassDeclaration(new JS.ClassExpression(
- new JS.Identifier(element.name), _classHeritage(element), []));
+ new JS.Identifier(element.name), _classHeritage(element), body));
return _finishClassDef(element.type, classDecl);
}
@@ -354,7 +367,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
@override
JS.Statement visitClassDeclaration(ClassDeclaration node) {
- // If we've already emitted this class, skip it.
var classElem = node.element;
var type = classElem.type;
var jsName = findAnnotation(classElem, _isJsNameAnnotation);
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698