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

Unified Diff: tool/input_sdk/private/ddc_runtime/classes.dart

Issue 1965213003: simplify constructors, fixes #564 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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 | « test/codegen/expect/temps.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/ddc_runtime/classes.dart
diff --git a/tool/input_sdk/private/ddc_runtime/classes.dart b/tool/input_sdk/private/ddc_runtime/classes.dart
index 722aa0c0979807294cf8da9c50684c00bb1b295f..1bf1fd66d643e68b8d0fbc96acdebee913b14d73 100644
--- a/tool/input_sdk/private/ddc_runtime/classes.dart
+++ b/tool/input_sdk/private/ddc_runtime/classes.dart
@@ -26,25 +26,21 @@ mixin(base, @rest mixins) => JS('', '''(() => {
// super, we can correctly initialize base and mixins.
// Create a class that will hold all of the mixin methods.
- class Mixin extends $base {
- // Initializer method: run mixin initializers, then the base.
- [$base.name](...args) {
- // Run mixin initializers. They cannot have arguments.
- // Run them backwards so most-derived mixin is initialized first.
- for (let i = $mixins.length - 1; i >= 0; i--) {
- let mixin = $mixins[i];
- let init = mixin.prototype[mixin.name];
- if (init) init.call(this);
- }
- // Run base initializer.
- let init = $base.prototype[base.name];
- if (init) init.apply(this, args);
- }
- }
+ class Mixin extends $base {}
// Copy each mixin's methods, with later ones overwriting earlier entries.
for (let m of $mixins) {
$copyProperties(Mixin.prototype, m.prototype);
}
+ // Initializer method: run mixin initializers, then the base.
+ Mixin.prototype.new = function(...args) {
+ // Run mixin initializers. They cannot have arguments.
+ // Run them backwards so most-derived mixin is initialized first.
+ for (let i = $mixins.length - 1; i >= 0; i--) {
+ $mixins[i].prototype.new.call(this);
+ }
+ // Run base initializer.
+ $base.prototype.new.apply(this, args);
+ };
// Set the signature of the Mixin class to be the composition
// of the signatures of the mixins.
« no previous file with comments | « test/codegen/expect/temps.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698