paulk-asert commented on PR #3052:
URL: https://github.com/apache/groovy/pull/3052#issuecomment-6494751582

   Thanks @daniellansun. Pushed f16a2f1, rebased on master now that #3044 is 
merged.
   
   Blocking: outer == null admits too much. Agreed, and it was worse than 
lenient: the branch admitted a precompiled private member type, which doesn't 
work at runtime. @CompileStatic code in another package reading 
lib.Lib.Hidden.x compiled and then threw IllegalAccessError, where 6.0.0 
rejected it at compile time. That branch now follows javac:
   - private is never accessible. A nest lies within one source unit, so a 
precompiled member type can't share the accessor's nest. This rejects the 
same-package case too, consistent with how master (after #3044) treats a source 
member type of another top-level class.
   - package-private is accessible from the same package only.
   - protected is still admitted without the subclass check. Without the 
enclosing type, the method can't make it. Its class file marks it public, so 
the access can't fail at runtime; the only difference from javac is that we 
accept it. The Javadoc now gives the reasoning for each case, so nobody 
tightens or loosens it without context. If your review text (it cuts off at 
"The new branch:") was also about protected, I can follow up once #3077's 
outer-class data is available for classes read from bytecode.
   
   1. #3044. Rebased on it. Its tests in FieldsAndPropertiesSTCTest, the write, 
attribute, closure, enum and other-top-level-class negative cases, are on 
master and pass unchanged. The early return it added is subsumed by the private 
branch here.
   
   2. Same-unit test. testProtectedMemberTypeFromSubclassBodyInSameUnit now 
compiles to a temp dir, loads the classes and asserts run() == 'ff'.
   
   3. Negatives. Added:
   - protected member type from a non-subclass in another package (same unit)
   - package-private member type from another package, both in the same unit 
and precompiled
   - precompiled private member type, from the same package and from another 
package, loaded both from a Class and from class files
   
   The two private tests fail without the change.
   
   Groovy12537 passes 9/9. groovy.transform.stc.*, 
org.codehaus.groovy.classgen.asm.sc.*, bugs.* and gls.innerClass.* pass (6,400 
tests, 0 failures).


-- 
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]

Reply via email to