paulk-asert commented on code in PR #2842:
URL: https://github.com/apache/groovy/pull/2842#discussion_r3889224932
##########
src/test/groovy/org/codehaus/groovy/transform/packageScope/DifferentPackageTest.groovy:
##########
@@ -367,7 +367,8 @@ final class DifferentPackageTest {
'''
)
}
- assert err.message =~ /Access to p.One#value is forbidden/
+ // GROOVY-12314: rejected by the type checker, no longer during class
generation
+ assert err.message =~ /No such property: value for class: p.One/
Review Comment:
You're right, and I checked what javac does to make sure I wasn't just
moving the boundary arbitrarily. javac reports an access error (value is not
public in One; cannot be accessed from outside package) for both the qualified
and the inherited case — but its resolution still treats the inaccessible field
as absent: an inner class extending p.One whose outer class also has a value
compiles and picks the outer one (JLS 8.2, "not inherited"). So the two halves
are: absent for resolution, access error for diagnosis. I'd only done the first
half.
4e7b0d11ad adds the second: resolution still falls through (accessor,
extension, map/list, enclosing scope), but when nothing else resolves the
property and the field is declared by the receiver's own class, STC now reports
Cannot access field: value of class: p.One from class: q.Two instead of "No
such property". The two expectations in this test assert that message now.
Two boundaries I left where they were, so this PR doesn't relitigate older
decisions — happy to widen them if you think we should: private fields stay
hidden (GROOVY-12290), and an inaccessible inherited field still reports "No
such property" for the subclass (GROOVY-9093, GROOVY-9293), on the JLS 8.2
ground that it isn't a member of that class. javac would say "not public / has
private access" in those cases too, so the fully consistent version is a
one-line condition plus updated expectations in those tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]