Skip to content

Add quick fix for attempt to override final method #612

@eric-milles

Description

@eric-milles

This test case produces the error for trying to override a final method. In the Java Editor, there is a quick fix provided: "Remove 'final' modifier of 'Foo.meth'(..)"

    @Test
    public void testOverriding_FinalMethod1() {
        runNegativeTest(new String[] {
            "Bar.groovy",
            "class Bar {\n" +
            "  final def getFinalProperty() {}\n" +
            "}\n",

            "Foo.groovy",
            "class Foo extends Bar {\n" +
            "  def getFinalProperty() {}\n" +
            "}\n",
        },
        "----------\n" +
        "1. ERROR in Foo.groovy (at line 2)\n" +
        "\tdef getFinalProperty() {}\n" +
        "\t    ^^^^^^^^^^^^^^^^\n" +
        "Groovy:You are not allowed to override the final method getFinalProperty() from class 'Bar'.\n" +
        "----------\n");
    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions