New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@override docs clarification #43622
Comments
No, the annotation doesn't impact performance. The purpose of the annotation is to express intent to the static analysis tooling. In this case it lets the tool know that you defined the method in order to override (or implement) behavior from a supertype. If the supertype changes such that the method is no longer overriding the method it once was (for example, if the method was removed or renamed) then the tooling can let you know that your implementation might need to be updated in response to that change. Having the annotation helps the tooling find potential errors statically. |
Yes, but why does the docs say we should use it judiciously? |
That I don't know. In the We even go so far as to use the |
cc @munificent |
The If we added the annotation today, the annotation would just have been added to The documentation was written by someone who didn't feel strongly that it should be used everywhere it could (because it adds a lot of syntactic overhead and clutter for little perceived benefit), but you should only use it to detect breakage across boundaries where you don't control both ends. That's what the documentation states. Use it if you judge that it brings you a benefit, and don't if you don't want to. The language, and the language style guide, does not recommend either direction, it's entirely up to you. People have generally chosen to use it everywhere, so the documentation is probably a little outdated compared to actual current usage. |
The
@override
docs sayUse the @override annotation judiciously
, but there's no reason why. Does it have any compiler performance impacts?The text was updated successfully, but these errors were encountered: