Awesome. Thanks for the clarification.
@override and @inheritDoc
When overriding a method, it should have either the@overrideor the@inheritDocannotation. The@overrideannotation should be used when there is additional information to include in the documentation of the method. For example, if the overridden method returns a subclass of the return type specified by the original method, then that should be documented with@override:
/** @return {example.House} */
example.Person.prototype.getDwelling = function() { /* ... */ };
/**
* In this example, RichPerson is a subclass of Person.
* @return {example.Mansion}
* @override
*/
example.RichPerson.prototype.getDwelling = function() { /* ... */ };
The@overrideannotation should also be used when the method signature is the same, but the documentation needs to be updated:
/** @return {string} A description of this object. */
Object.prototype.toString = function() { /* ... */ };
/**
* @return {string} The format of the string will be "(x,y)".
* @override
*/
Point.prototype.toString = function() { /* ... */ };
If there is no need to update the documentation for the overridden method, then@inheritDocshould be used without any other annotations. When viewing a method marked with@inheritDoc, you can assume that the contract of the original method applies to the overridden method. Further, the@inheritDocannotation implies the@overrideannotation, so there is no need to include both.
Because most subclass methods maintain the contract of the original method (or because programmers are too lazy to clarify the behavior of a subclass),@inheritDocis used more often than@override, in practice.
--To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/47f56527-2778-405b-9528-4b23bc2ce50c%40googlegroups.com.
---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-d...@googlegroups.com.
Le 31 août 2014 01:12, "Erik Neumann" <er...@myphysicslab.com> a écrit :
>
> Can someone provide more info on this? I'm using @inheritDoc everywhere now, do I need to change to use @override instead? How do you know that @inheritDoc is deprecated? I don't get any compiler errors (I last updated the compiler a couple months ago, Version: v20140625-8-g6442298).
I'd have the same questions...
--
---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/CAGZ3h-Hmqj5yye4V7WkvhLDRBKbBs%3DX00_QCnD6%3DF9Lu_0RMfg%40mail.gmail.com.