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:
- Set the visibility of the override to match the overridden method
- 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");
}
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: