Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart |
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart |
index 7d48033577925893ea6a616c65b1ead567126a62..db8173c3226ba45514edf458302b1ac92bb4adbb 100644 |
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart |
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart |
@@ -33,7 +33,7 @@ mixin(base, @rest mixins) => JS( |
for (let m of $mixins) { |
$copyProperties(Mixin.prototype, m.prototype); |
} |
- // Initializer method: run mixin initializers, then the base. |
+ // Initializer methods: 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. |
@@ -43,6 +43,19 @@ mixin(base, @rest mixins) => JS( |
// Run base initializer. |
$base.prototype.new.apply(this, args); |
}; |
+ if ($base[$_namedConstructors] != null) { |
Jennifer Messerly
2017/05/03 19:43:55
Just noticed while working on another CL: this sho
|
+ for (let namedCtor of $base[$_namedConstructors]) { |
+ Mixin.prototype[namedCtor] = 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[namedCtor].apply(this, args); |
+ }; |
+ } |
+ } |
// Set the signature of the Mixin class to be the composition |
// of the signatures of the mixins. |
@@ -424,13 +437,16 @@ defineNamedConstructor(clazz, name) => JS( |
let proto = $clazz.prototype; |
let initMethod = proto[$name]; |
let ctor = function(...args) { initMethod.apply(this, args); }; |
- ctor[$isNamedConstructor] = true; |
+ if ($clazz[$_namedConstructors] == null) $clazz[$_namedConstructors] = []; |
+ $clazz[$_namedConstructors].push($name); |
ctor.prototype = proto; |
// Use defineProperty so we don't hit a property defined on Function, |
// like `caller` and `arguments`. |
$defineProperty($clazz, $name, { value: ctor, configurable: true }); |
})()'''); |
+final _namedConstructors = JS('', 'Symbol("_namedConstructors")'); |
+ |
final _extensionType = JS('', 'Symbol("extensionType")'); |
getExtensionType(obj) => JS('', '#[#]', obj, _extensionType); |