Skip to content

[Feature Request] ---@final to mark class method as non-overridableΒ #3215

@NyakoFox

Description

@NyakoFox

In languages like Java, you have the keyword final to indicate that a function should NOT be overridden. There doesn't seem to be any annotation like that yet. It should give a warning (or error?) if you try to override the function. Additionally, completion for function MyClass: could avoid suggesting anything with @final? You'd still be able to call it anywhere, just not override it if its now final.

(Maybe @final could also work on variables? Pretty much working the same way, just "don't override/set this but still be able to read it")

(Unrelated but I was thinking about ---@override to mark something as "you should override this and not call this" but it wouldn't be able to warn since your internal code needs to call it, so I'm not sure. Might just be good to have anyway, not as a warning but a tooltip thing.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions