google / google/closure-compiler
Static class functions can be erroneously removed in ADVANCED mode
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
In a simple example with ADVANCED optimizations enabled
```js
class Foo {
static print() {
console.log('f');
}
constructor() {
this.constructor.print();
}
}
let x = new Foo();
```
The call to the `print` function remains, but the implementation is missing.
```js
new function() {
this.constructor.print();
};
```
[Live Example](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%2540language_in%2520ES_6%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250Aclass%2520Foo%2520%257B%250A%2520%2520static%2520print()%2520%257B%250A%2520%2520%2520%2520console.log('f')%253B%250A%2520%2520%257D%250A%2520%2520constructor()%2520%257B%250A%2520%2520%2520%2520this.constructor.print()%253B%250A%2520%2520%257D%250A%257D%250A%250Alet%2520x%2520%253D%2520new%2520Foo()%253B%250A%250A)
Contributor guide
Assessment
This issue has not been assessed yet.