Skip to content

provide a more aesthetically pleasing @override #60025

@lukepighetti

Description

@lukepighetti

@override is currently optional. it makes classes longer and more verbose than they need to be. here are two ideas for improving the aesthetics and i'm happy to hear other ideas.

  1. deprecate @override
    1a. schedule it for removal from the language

pros: it's optional and not needed. deprecating it should be straightforward. removal could be scheduled out indefinitely or 5+ years

cons: it will be harder to tell which methods override superclass methods. maybe there are lsp features like virtual text that could help instead

(this one is my preference because perhaps due to my mechanical engineering background deleting things that are optional is basically a blood sport for people like me.)

  1. create an override keyword (see swift)
    2a. make this keyword required on a method if the superclass has a method with the same name
    2b. require removal of the keyword if it exists on a method who has no superclass with a matching method
    2c. deprecate @override and schedule for removal

pros: one line. explicitly marks overriding methods. make required instead of an optional warning as it currently is.

cons: makes class declaration lines longer. but that's less of an issue with configurable dart format line lengths

i'm personally less inclined to this option because it doesn't provide much value over what we currently have

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-duplicateClosed in favor of an existing reporttriage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions