[ 
https://issues.apache.org/jira/browse/GROOVY-12537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132749#comment-18132749
 ] 

ASF GitHub Bot commented on GROOVY-12537:
-----------------------------------------

codecov-commenter commented on PR #3052:
URL: https://github.com/apache/groovy/pull/3052#issuecomment-6436410556

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3052?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `66.66667%` with `5 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 73.6088%. Comparing base 
([`2412319`](https://app.codecov.io/gh/apache/groovy/commit/2412319b847e559850d96f1fd4168aa75eed9de9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`d1bfbc0`](https://app.codecov.io/gh/apache/groovy/commit/d1bfbc02c35e88aaad5b727d53d8ae3e05d1018d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on master.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3052?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3052?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nVmlzaXRvci5qYXZh)
 | 66.6667% | [1 Missing and 4 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3052?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3052/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/3052?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3052        +/-   ##
   ==================================================
   - Coverage     73.6146%   73.6088%   -0.0058%     
   - Complexity      42350      42352         +2     
   ==================================================
     Files            1657       1657                
     Lines          145702     145719        +17     
     Branches        27495      27505        +10     
   ==================================================
   + Hits           107258     107262         +4     
   - Misses          28469      28474         +5     
   - Partials         9975       9983         +8     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3052?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3052?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nVmlzaXRvci5qYXZh)
 | `87.4163% <66.6667%> (-0.0547%)` | :arrow_down: |
   
   ... and [16 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3052/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> STC: field access through a protected or doubly-nested private member type is 
> wrongly rejected as inaccessible
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12537
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12537
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 6.0.0
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>
> Description:
> Since GROOVY-12314, the type checker rejects a field access when the type 
> that qualifies it is not accessible from the calling class. The accessibility 
> check gets member types wrong in two cases, so valid code that compiled 
> before now fails under @CompileStatic and @TypeChecked:
> 1. A protected member type of a class compiled in an earlier step, used from 
> a subclass in another package:
> {code:groovy}
> // p/Base.groovy, compiled first
> package p
> class Base {
>     protected static class Prot { public static String F = 'f' }
> }
> {code}
> {code:groovy}
> // q/Sub.groovy, compiled with p.Base on the classpath
> package q
> @groovy.transform.CompileStatic
> class Sub extends p.Base {
>     static String run() { p.Base.Prot.F }
> }
> {code}
> {noformat}
> [Static type checking] - Cannot access field: F of class: p.Base$Prot from 
> class: q.Sub
> {noformat}
> 2. A private member type nested inside another member type, used from the 
> top-level class:
> {code:groovy}
> package q
> @groovy.transform.CompileStatic
> class Outer {
>     private static class A {
>         private static class B { public static String F = 'f' }
>     }
>     static String run() { A.B.F }
> }
> {code}
> {noformat}
> [Static type checking] - Cannot access field: F of class: q.Outer$A$B from 
> class: q.Outer
> {noformat}
> Java accepts both (JLS 6.6.1, 6.6.2), and both compiled and ran before 
> GROOVY-12314.
> Cause: StaticTypeCheckingVisitor#hasAccessToClass checks a member type's 
> modifiers with the rule used for members, using the enclosing type as the 
> receiver:
> * For a type compiled in an earlier step, ClassNode#getOuterClass() is null, 
> so the enclosing type is unknown. A protected member type is then checked 
> against itself, and no subclass derives from it.
> * Protected access is checked against the calling class alone. JLS 6.6.2 
> allows it anywhere in the body of the subclass, including its nested classes, 
> closures and anonymous classes.
> * Private access only allows the immediately enclosing type and classes 
> nested inside the private type. It should allow anything in the same nest, as 
> the existing inSameNest check does.
> Proposed fix: when the enclosing type is unknown, enforce only 
> package-private access, so the check rejects only what it can actually 
> decide. Otherwise, check the enclosing type's accessibility first, then: 
> public => accessible; private => same nest; same package as the enclosing 
> type => accessible; protected => the calling class or one of its enclosing 
> classes derives from the enclosing type. Every change here makes the rule 
> more permissive, so nothing the check accepts today will be rejected. The 
> GROOVY-12310 case (a package-private nested enum in a Java class) is still 
> rejected.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to