Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Return type annotations are formatted as method annotations #109

@mernst

Description

@mernst

The proper style for a type annotation is to write it immediately before the type that it annotates. For example, this is wrong:

@Interned
String m1() {
    return "foo bar";
}

and this is correct:

@Interned String m1() {
    return "foo bar";
}

However, the insert-annotations-to-source program produces the former rather than the latter.

The same thing goes for fields: the annotation should be on the same line as the type, not above the type and indented.

I have attached files that reproduce the problem and that show the desired output. Run the following commands:

javac MethodReturnTest3.java
insert-annotations-to-source MethodReturnTest3.jaif MethodReturnTest3.java

type-annotation-formatting.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions