Skip to content

@final not checked when method is overridden by setting prototype #1841

Open
@mgiuffrida

Description

@mgiuffrida

The docs imply that @final on a class method makes it an error to override that method in a subclass:

/** @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:

MyChildClass.prototype.method = function() {};  // does fail

for closure-compiler to notice this mistake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions