google / closure-compiler

A JavaScript checker and optimizer.
https://developers.google.com/closure/compiler/
Apache License 2.0
7.4k stars 1.15k forks source link

goog.abstractMethod vs @abstract #1988

Open fredj opened 8 years ago

fredj commented 8 years ago

Since 08606a76, the compiler warn if abstract methods appear in concrete classes:

/**
 * @abstract
 * @constructor
 */
C = function() {
  this.foo = -1;
};

/**
 * @abstract
 */
C.prototype.add = function() {};

But it is not the case when goog.abstractMethod is used:

/**
 * @constructor
 */
C = function() {
  this.foo = -1;
};

/**
 *
 */
C.prototype.add = goog.abstractMethod;

(and goog.abstractMethod doesn't require the constructor to be abstract.)

Dominator008 commented 8 years ago

I haven't added this warning to goog.abstractMethod due to the risk of breaking many internal projects at Google.