| Index: sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
|
| index 6c266153502120b97a67edcb207ad9877eaddfc2..42d40bf0caecf8c76646c1abfc15aba764412e20 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
|
| @@ -312,9 +312,11 @@ class OldEmitter implements Emitter {
|
| tmp.prototype = superConstructor.prototype;
|
| var object = new tmp();
|
| var properties = constructor.prototype;
|
| - for (var member in properties)
|
| - if (hasOwnProperty.call(properties, member))
|
| + for (var member in properties) {
|
| + if (hasOwnProperty.call(properties, member)) {
|
| object[member] = properties[member];
|
| + }
|
| + }
|
| object.constructor = constructor;
|
| constructor.prototype = object;
|
| return object;
|
| @@ -323,6 +325,24 @@ class OldEmitter implements Emitter {
|
| ''')];
|
| }
|
|
|
| + List buildSplitOffAliases() {
|
| + return [js(r'''
|
| + var splitOffAliases = function(constructor) {
|
| + var hasOwnProperty = Object.prototype.hasOwnProperty;
|
| + var properties = constructor.prototype;
|
| + for (var member in properties) {
|
| + if (hasOwnProperty.call(properties, member)) {
|
| + var s = member.split(':');
|
| + if (s.length > 1) {
|
| + properties[s[0]] = properties[s[1]] = properties[member];
|
| + delete properties[member];
|
| + }
|
| + }
|
| + }
|
| + }
|
| + ''')];
|
| + }
|
| +
|
| jsAst.Fun get finishClassesFunction {
|
| // Class descriptions are collected in a JS object.
|
| // 'finishClasses' takes all collected descriptions and sets up
|
| @@ -373,8 +393,8 @@ class OldEmitter implements Emitter {
|
| if (desc instanceof Array) desc = desc[1];
|
|
|
| /* The 'fields' are either a constructor function or a
|
| - * string encoding fields, constructor and superclass. Get
|
| - * the superclass and the fields in the format
|
| + * string encoding fields, constructor and superclass. Gets the
|
| + * superclass and fields in the format
|
| * '[name/]Super;field1,field2'
|
| * from the CLASS_DESCRIPTOR_PROPERTY property on the descriptor.
|
| * The 'name/' is optional and contains the name that should be used
|
| @@ -497,6 +517,11 @@ class OldEmitter implements Emitter {
|
| finishedClasses[cls] = true;
|
|
|
| var superclass = pendingClasses[cls];
|
| + var constructor = allClasses[cls];
|
| +
|
| + // Process aliased members due to super calls. We have to do this early
|
| + // to ensure that we also hit the object class.
|
| + splitOffAliases(constructor);
|
|
|
| // The superclass is only false (empty string) for the Dart Object
|
| // class. The minifier together with noSuchMethod can put methods on
|
| @@ -504,7 +529,6 @@ class OldEmitter implements Emitter {
|
| // that we have a string.
|
| if (!superclass || typeof superclass != "string") return;
|
| finishClass(superclass);
|
| - var constructor = allClasses[cls];
|
| var superConstructor = allClasses[superclass];
|
|
|
| if (!superConstructor)
|
| @@ -672,6 +696,7 @@ class OldEmitter implements Emitter {
|
| if (!needsDefineClass) return [];
|
| return defineClassFunction
|
| ..addAll(buildInheritFrom())
|
| + ..addAll(buildSplitOffAliases())
|
| ..addAll([
|
| js('$finishClassesName = #', finishClassesFunction)
|
| ]);
|
|
|