Fixes #2749. Restricting to instance methods in class bodies, where it actually has a chance in hell of calling the correct thing.
This commit is contained in:
parent
667b96b495
commit
47f0ea69b8
|
@ -796,23 +796,19 @@
|
|||
};
|
||||
|
||||
Call.prototype.superReference = function(o) {
|
||||
var accesses, method, name;
|
||||
var accesses, method;
|
||||
method = o.scope.namedMethod();
|
||||
if (!method) {
|
||||
throw SyntaxError('cannot call super outside of a named function.');
|
||||
}
|
||||
name = method.name;
|
||||
if (method.klass) {
|
||||
if (method != null ? method.klass : void 0) {
|
||||
accesses = [new Access(new Literal('__super__'))];
|
||||
if (method["static"]) {
|
||||
accesses.push(new Access(new Literal('constructor')));
|
||||
}
|
||||
accesses.push(new Access(new Literal(name)));
|
||||
accesses.push(new Access(new Literal(method.name)));
|
||||
return (new Value(new Literal(method.klass), accesses)).compile(o);
|
||||
} else if (method.ctor) {
|
||||
return "" + name + ".__super__.constructor";
|
||||
} else if (method != null ? method.ctor : void 0) {
|
||||
return "" + method.name + ".__super__.constructor";
|
||||
} else {
|
||||
return "this.constructor.__super__." + name;
|
||||
throw SyntaxError('cannot call super outside of an instance method.');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -515,17 +515,15 @@ exports.Call = class Call extends Base
|
|||
# method.
|
||||
superReference: (o) ->
|
||||
method = o.scope.namedMethod()
|
||||
throw SyntaxError 'cannot call super outside of a named function.' unless method
|
||||
{name} = method
|
||||
if method.klass
|
||||
if method?.klass
|
||||
accesses = [new Access(new Literal '__super__')]
|
||||
accesses.push new Access new Literal 'constructor' if method.static
|
||||
accesses.push new Access new Literal name
|
||||
accesses.push new Access new Literal method.name
|
||||
(new Value (new Literal method.klass), accesses).compile o
|
||||
else if method.ctor
|
||||
"#{name}.__super__.constructor"
|
||||
else if method?.ctor
|
||||
"#{method.name}.__super__.constructor"
|
||||
else
|
||||
"this.constructor.__super__.#{name}"
|
||||
throw SyntaxError 'cannot call super outside of an instance method.'
|
||||
|
||||
# The appropriate `this` value for a `super` call.
|
||||
superThis : (o) ->
|
||||
|
|
Loading…
Reference in New Issue