mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:37:53 +00:00
One more minor mixin fix
We need to preserve the Mixin constructor to make sure metadata (e.g., implements) is injected in the right place. R=jacobr@google.com Review-Url: https://codereview.chromium.org/2779063002 .
This commit is contained in:
parent
746ab58f46
commit
92d39a4e08
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -191,8 +191,6 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'is', 'require'],
|
|||
'memory_swap_test': skip_timeout,
|
||||
'method_invocation_test': fail,
|
||||
'mint_arithmetic_test': fail,
|
||||
'mixin_implements_test': fail,
|
||||
'mixin_regress_13688_test': fail,
|
||||
'mixin_super_constructor_positionals_test_none_multi': fail, // Issue 28059
|
||||
'modulo_test': fail,
|
||||
'named_parameter_clash_test': fail,
|
||||
|
|
|
@ -29,10 +29,16 @@ mixin(base, @rest mixins) => JS(
|
|||
|
||||
// Create a class that will hold all of the mixin methods.
|
||||
class Mixin extends $base {}
|
||||
// Save the original constructor. For ClassTypeAlias definitions, this
|
||||
// is the concrete type. We embed metadata (e.g., implemented interfaces)
|
||||
// on this constructor and need to access that from runtime instances.
|
||||
let constructor = Mixin.prototype.constructor;
|
||||
// Copy each mixin's methods, with later ones overwriting earlier entries.
|
||||
for (let m of $mixins) {
|
||||
$copyProperties(Mixin.prototype, m.prototype);
|
||||
}
|
||||
// Restore original Mixin constructor.
|
||||
Mixin.prototype.constructor = constructor;
|
||||
// Initializer methods: run mixin initializers, then the base.
|
||||
Mixin.prototype.new = function(...args) {
|
||||
// Run mixin initializers. They cannot have arguments.
|
||||
|
@ -55,6 +61,7 @@ mixin(base, @rest mixins) => JS(
|
|||
// Run base initializer.
|
||||
$base.prototype[namedCtor].apply(this, args);
|
||||
};
|
||||
$defineNamedConstructor(Mixin, namedCtor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,6 +633,10 @@ defineNamedConstructorCallable(clazz, name, ctor) => JS(
|
|||
// Use defineProperty so we don't hit a property defined on Function,
|
||||
// like `caller` and `arguments`.
|
||||
$defineProperty($clazz, $name, { value: ctor, configurable: true });
|
||||
|
||||
let namedCtors = ${safeGetOwnProperty(clazz, _namedConstructors)};
|
||||
if (namedCtors == null) $clazz[$_namedConstructors] = namedCtors = [];
|
||||
namedCtors.push($name);
|
||||
})()''');
|
||||
|
||||
defineEnumValues(enumClass, names) => JS(
|
||||
|
|
Loading…
Reference in a new issue