[
https://issues.apache.org/jira/browse/GROOVY-12713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139964#comment-18139964
]
ASF GitHub Bot commented on GROOVY-12713:
-----------------------------------------
codecov-commenter commented on PR #3244:
URL: https://github.com/apache/groovy/pull/3244#issuecomment-6697388243
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3244?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 `64.28571%` with `20 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 74.3340%. Comparing base
([`5170b46`](https://app.codecov.io/gh/apache/groovy/commit/5170b4661350aed26bab4407fa66c68eecb86fc5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`ffe0276`](https://app.codecov.io/gh/apache/groovy/commit/ffe0276086659bb4dac0674a7715cc97ef8011d0?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/3244?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/3244?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)
| 64.2857% | [3 Missing and 17 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3244?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/3244?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3244 +/- ##
==================================================
- Coverage 74.3428% 74.3340% -0.0088%
+ Complexity 44310 44309 -1
==================================================
Files 1699 1699
Lines 150862 150892 +30
Branches 28756 28768 +12
==================================================
+ Hits 112155 112164 +9
- Misses 28435 28443 +8
- Partials 10272 10285 +13
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3244?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/3244?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.9141% <64.2857%> (-0.1312%)` | :arrow_down: |
... and [12 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3244/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>
> Static type checking rejects nested copyWith: dotted keys are "unexpected
> named arg" and the block form's properties are undeclared
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12713
> URL: https://issues.apache.org/jira/browse/GROOVY-12713
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 6.0.0
> Environment: Groovy 6.0.0 binary distribution and master 7379c5720d;
> BellSoft JDK 21.0.12; macOS 15 arm64
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> GROOVY-12015 (6.0.0-alpha-2) gave the generated {{copyWith}} of records and
> {{@Immutable}} classes dotted-path keys ({{copyWith('address.city':
> 'Paris')}}) and a block form ({{copyWith { address.city = 'Paris' }}}). Both
> work in dynamic code; neither passes static type checking, while the
> single-level named-argument form does. On 6.0.0 and master:
> {code:groovy}
> import groovy.transform.CompileStatic
> import groovy.transform.RecordOptions
> @RecordOptions(copyWith = true)
> record Address(String street, String city) {}
> @RecordOptions(copyWith = true)
> record Customer(String name, Address address) {}
> @CompileStatic
> class Demo {
> static void main(String[] args) {
> Customer c = new Customer('Ada', new Address('1 Main St', 'Lyon'))
> println c.copyWith(name: 'Bob') // accepted
> println c.copyWith('address.city': 'Paris') // line 14
> println c.copyWith { address.city = 'Rome' } // line 15
> }
> }
> {code}
> {noformat}
> Copy.groovy: 14: [Static type checking] - unexpected named arg: address.city
> Copy.groovy: 15: [Static type checking] - The variable [address] is
> undeclared.
> {noformat}
> Without {{@CompileStatic}} the same file prints the three copies.
> Causes: the record and immutable transforms annotate the generated
> {{copyWith(Map)}} parameter with one {{@NamedParam}} per component, and
> {{StaticTypeCheckingVisitor.checkNamedParamsAnnotation}} reports any key that
> is not one of them, so a dotted path is "unexpected" although the generated
> method accepts it ({{NestedCopyWithSupport.flatten}} resolves it at run
> time). The block form's closure runs with a {{CopyWithRecorder}} delegate
> that the type checker knows nothing about, so the assignments' targets are
> undeclared variables. The documentation of {{RecordOptions.copyWith}}
> describes both forms without a static-typing caveat.
> Suggested fix for the dotted keys: in the named-argument check, accept a
> dotted key when each segment is a named parameter of the type reached so far
> (the {{type}} member of the previous segment's {{@NamedParam}}, whose own
> {{copyWith(Map)}} declares the next level), report an unknown segment as
> before, and check the value against the last segment's declared type. Pull
> request to follow. The block form needs the type checker to model the
> recorder (the record type as the closure's delegate, with writes to its
> read-only properties and {{old}} allowed inside that block); that is a
> follow-up.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)