Skip to content

Request annotation for instance methods that return "this" or some instance of the type of "this" #46

@cbfiddle

Description

@cbfiddle

I'm requesting an annotation, I'll call it @ThisType, that can be attached to the return type of an instance method declared to return the type of the class containing the method definition.

For example:

abstract class Animal {
    public abstract @ThisType Animal copy();
}

I intend this annotation to have this effect on the IDE:
If an overriding method is created in a subclass, the return type is set to the subclass type.

For example, if I create a subclass Dog and use the Override Methods... action to override this method, the method that is created is:

@Override
public @ThisType Dog copy() {
    return null;
}

It would also be useful to have a quick way to override all of the @ThisType methods.

This feature would make implementing fluent APIs with subclasses a bit easier.

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