It is currently possible to shadow the superclass in a method by locally redefining its name.
This causes problems when using the super keyword to call a super method:
class SomeClass {
method() {
console.log("Super.method");
}
}
export public class Nested extends SomeClass {
a() {
var SomeClass = 4;
super.method();
}
}
var n = new Nested();
n.a();
The execution of this script results in the following output
(SystemJS) Cannot read property 'method' of undefined
TypeError: Cannot read property 'method' of undefined
at Nested.a___n4 (.../n4js-master-two/Eclipse.app/Contents/MacOS/workspace/InterfaceSuperAccess/src-gen/es/InterfaceSuperAccess/Nested.js:43:27)
at execute (.../n4js-master-two/Eclipse.app/Contents/MacOS/workspace/InterfaceSuperAccess/src-gen/es/InterfaceSuperAccess/Nested.js:73:7)
Error loading InterfaceSuperAccess/Nested
In the following snippet from the generated code, the cause of the issue becomes clear:
...
$makeClass(Nested, SomeClass, [], {
a: {
value: function a___n4() {
var SomeClass = 4;
SomeClass.prototype.method.call(this);
}
}
},...
Moved: https://github.com/eclipse/n4js/issues/75
It is currently possible to shadow the superclass in a method by locally redefining its name. This causes problems when using the super keyword to call a super method:
The execution of this script results in the following output
In the following snippet from the generated code, the cause of the issue becomes clear: