google / google/closure-compiler
@final not checked when method is overridden by setting prototype
Open
OTI
P3
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
The docs imply that `@final` on a class method makes it an error to override that method in a subclass:
``` js
/** @constructor */
function MyClass() {}
/** @final */
MyClass.prototype.method = function() {};
/**
* @constructor
* @extends {MyClass}
*/
function MyChildClass() {}
MyChildClass.prototype = {
__proto__: MyClass,
/** @override */
method: function() {}, // should fail
};
```
But this doesn't error. The method has to be set separately:
``` js
MyChildClass.prototype.method = function() {}; // does fail
```
for closure-compiler to notice this mistake.
Contributor guide
Assessment
This issue has not been assessed yet.