Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.6
-
None
Description
Take the following code:
import groovy.transform.CompileStatic @CompileStatic class Outer { private int outerField = 1 private int outerMethod() { 2 } int outerProperty = 3 class Inner { void assertions() { assert outerField == 1 // #1 assert outerMethod() == 2 // #2 assert outerProperty == 3 // #3 //assert getOuterProperty() == 4 // #4 } } void test() { new Inner().assertions() } } new Outer().test()
Assertion #2 fails at runtime with:
Cannot find matching method Outer$Inner#getOuterProperty()
which makes me think that the type checker does know that the method belongs to the outer class, but the receiver is not loaded properly. In fact, it should use a generated bridge method for the private method here.
Uncommenting #4 leads to a static type checking error, which indicates that the getXXX method call is not checking that a property can be defined in an outer class.