[
https://issues.apache.org/jira/browse/GROOVY-12290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107051#comment-18107051
]
ASF GitHub Bot commented on GROOVY-12290:
-----------------------------------------
codecov-commenter commented on PR #2828:
URL: https://github.com/apache/groovy/pull/2828#issuecomment-5384795541
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2828?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 `93.75000%` with `1 line` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 70.2571%. Comparing base
([`01f91d4`](https://app.codecov.io/gh/apache/groovy/commit/01f91d475918156df6c290460c70e3c7dfbe1e36?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`6ffd88c`](https://app.codecov.io/gh/apache/groovy/commit/6ffd88cdb7b59385405e933459b085a4889eac82?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 3 commits behind head on master.
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2828?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/2828?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)
| 93.7500% | [0 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2828?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>
[](https://app.codecov.io/gh/apache/groovy/pull/2828?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2828 +/- ##
==================================================
- Coverage 70.2594% 70.2571% -0.0024%
- Complexity 36274 36284 +10
==================================================
Files 1569 1569
Lines 133723 133736 +13
Branches 24637 24645 +8
==================================================
+ Hits 93953 93959 +6
- Misses 31257 31262 +5
- Partials 8513 8515 +2
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2828?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/2828?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.2251% <93.7500%> (+0.0412%)` | :arrow_up: |
... and [11 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2828/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>
> Private field access from another class compiles under @TypeChecked but fails
> under @CompileStatic
> --------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12290
> URL: https://issues.apache.org/jira/browse/GROOVY-12290
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Priority: Major
>
> Accessing a private field of another class via property syntax compiles under
> {{@TypeChecked}} (and runs, thanks to dynamic dispatch's historical leniency
> about {{private}}) but fails to compile under {{@CompileStatic}}:
> {code:groovy}
> class P { private static final Map M = [a: 1] }
> class C {
> @groovy.transform.TypeChecked
> def tc() { P.M } // compiles, runs
> @groovy.transform.CompileStatic
> def cs() { P.M } // "Access to P#M is forbidden"
> }
> {code}
> The equivalent *method* case is already consistent: STC's method selection
> filters candidates by visibility, so a private static method of another class
> is rejected with the same {{[Static type checking]}} error in both modes.
> Field/property resolution performed no such check — the receiver-type
> leniency (GROOVY-7300, GROOVY-11358, which models dynamic Groovy's permissive
> private access) admitted the field, and the access was only refused later, at
> bytecode generation, by {{StaticTypesCallSiteWriter}} ({{"Access to X#Y is
> forbidden"}}) when it must emit a direct field access and no private-access
> bridge exists. Compilation modes should not disagree: whatever passes type
> checking should statically compile (same principle as GROOVY-12289).
> *Fix:* the receiver-type leniency (extracted to
> {{StaticTypeCheckingVisitor#isFieldAccessible}}) no longer admits plain
> property syntax to a private field of a foreign nest, so both modes report
> the standard {{No such property}} error at type-checking time (see also
> GROOVY-7165, whose expected error moves from the late writer message to the
> STC one). The deliberate dynamic escape hatches — which work at runtime in
> *all three* modes today — are preserved:
> * attribute access ({{new P().@f}}), Groovy's explicit encapsulation-piercing
> operator
> * closure bodies (GROOVY-9195), including delegate-resolved access ({{new
> P().with \{ f \}}} and DSL/builder patterns generally) — closure property
> dispatch stays dynamic-capable under static compilation
> * nest-mate access via private bridges: closures reading the owner's private
> fields, inner classes reading outer private statics, trait-private fields
> * property syntax that resolves to an accessible accessor over a private field
> Related adjustments:
> * An inaccessible field no longer suppresses the read-only-property detection
> (GROOVY-9127), so a class with a public getter, an out-of-scope setter and a
> private field now reports {{Cannot set read-only property}} — identically in
> both modes. This supersedes the GROOVY-11956 expectation that the map-style
> constructor case compiles under {{@TypeChecked}} and fails only under
> {{@CompileStatic}} (late, in the writer): it now fails consistently, arguably
> completing that ticket's read-only story.
> * Record component accessors ({{x()}} on precompiled records) now resolve in
> STC's getter lookup, relocating the GROOVY-12225 writer-side fix: {{p.x}}
> types via the accessor instead of leaning on the removed field leniency.
> *Not changed:* the GROOVY-9195 closure exemption preserves a pre-existing
> asymmetry — foreign-private field access is rejected in method bodies but
> permitted in closure bodies (where it compiles to dynamic dispatch and
> works). Unifying that would be a further behavior change with real DSL
> fallout, so it is documented rather than removed.
> *Migration note:* code that today compiles and runs under {{@TypeChecked}}
> only (e.g. tests or frameworks reading another class's internals via property
> syntax from a method body) becomes a compile error. Workarounds are
> straightforward ({{@PackageScope}}, an accessor, explicit {{.@}}, or a
> type-checking extension — the error goes through the unresolved-property
> path, so {{handleUnresolvedProperty}}/{{makeDynamic}} work as escape
> hatches). This tightening should be called out in release notes and targeted
> at Groovy 6.
> Dynamic Groovy is unaffected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)