You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we were to accept the proposal to make override a language feature, would we also want to make the redeclare annotation a language feature? It serves a similar function, but for extension types.
The text was updated successfully, but these errors were encountered:
The override has the effect of documenting intent, making it clear that something is intended to override an existing member, that it is the same virtual member, and that it has an existing signature to satisfy. Someone calling the overridden function at a supertype will get this overriding implementation. Also, because of the explicit link to the superinterface signature, you can get extra benefits in the overriding member (like type inheritance).
The redeclare doesn't have a signature to satisfy, and the method is not accessible to someone trying to call the redeclared member on a supertype. It's an unrelated member with the same name.
The means it's not so much showing intent to be the same thing, as it acknowledging that two unrelated things have the same type, and one is shadowing another. With extension methods and extension type methods, you get what you ask for. (Why are those not both affected by @redeclare?)
The "don't redeclare" lint is not a lint I'd personally enable, and therefore not an annotation I'd use, so it's not surprising that I don't think it carries its own weight as a language feature. Others may disagree.
lrhn
changed the title
Making override a language feature
Making redeclare a language feature?
Sep 23, 2024
If we were to accept the proposal to make override a language feature, would we also want to make the
redeclare
annotation a language feature? It serves a similar function, but for extension types.The text was updated successfully, but these errors were encountered: