google / google/closure-compiler
StaticSuperPropReplacer not compatible with static inheritance
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
The StaticSuperPropReplacer pass does not properly account for static inheritance. The following case demonstrates code that is broken by the pass.
```js
class Base {
static foo() {
console.log('base foo');
}
static bar() {
this.foo();
}
}
class Intermediate extends Base {
static baz() {
super.bar(); // changing `super` to `Base` changes `this` in the super call.
}
}
class Child extends Intermediate {
static foo() {
console.log('child foo');
}
}
Child.baz(); // should log "child foo"
```
This pattern occurs in Polymer: https://github.com/Polymer/polymer/blob/d577c8c8755b3078da605889488e8988eb31c48d/lib/mixins/template-stamp.js#L348
Contributor guide
Assessment
This issue has not been assessed yet.