Skip to content

Add quick fixes for fixing modifiers when attempting to reduce visibility of override method #611

@eric-milles

Description

@eric-milles

This test case produces the error for trying to reduce the visibility when overriding a method. In the Java Editor, there are 2 quick fixes provided:

  1. Set the visibility of the override to match the overridden method
  2. Set the visibility of the overridden method to match the override method
    @Test
    public void testOverriding_ReducedVisibility1() {
        runNegativeTest(new String[] {
            "Bar.groovy",
            "class Bar { public void baz() {} }\n",

            "Foo.groovy",
            "class Foo extends Bar { private void baz() {}\n }\n",
        }, "----------\n" +
            "1. ERROR in Foo.groovy (at line 1)\n" +
            "\tclass Foo extends Bar { private void baz() {}\n" +
            "\t                                     ^^^\n" +
            "Groovy:baz() in Foo cannot override baz in Bar; attempting to assign weaker access privileges; was public\n" +
            "----------\n");
    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions