[
https://issues.apache.org/jira/browse/GROOVY-12713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140680#comment-18140680
]
ASF GitHub Bot commented on GROOVY-12713:
-----------------------------------------
testlens-app[bot] commented on PR #3244:
URL: https://github.com/apache/groovy/pull/3244#issuecomment-6720288554
## 🚨 All tests passed but jobs failed 🚨
### Failed Jobs without Test Failures
❌ [Build and test / lts \(17,
ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/42470637139/job/128700322378?pr=3244)
❌ [Build and test / lts \(21,
ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/42470637139/job/128700322233?pr=3244)
❌ [Build and test / lts \(25,
ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/42470637139/job/128700322432?pr=3244)
❌ [Build and test for coverage /
test](https://github.com/apache/groovy/actions/runs/42470637107/job/128700321667?pr=3244)
❌ [CodeQL / Analyze \(java,
21\)](https://github.com/apache/groovy/actions/runs/42470637124/job/128700321683?pr=3244)
❌ [Generate SNAPSHOT artifacts /
dist](https://github.com/apache/groovy/actions/runs/42470637131/job/128700321930?pr=3244)
❌ [Generate SNAPSHOT distributions /
dist](https://github.com/apache/groovy/actions/runs/42470637128/job/128700321874?pr=3244)
❌ [Lint gate /
lint](https://github.com/apache/groovy/actions/runs/42470637095/job/128700322035?pr=3244)
❌ [Performance check /
test](https://github.com/apache/groovy/actions/runs/42470637174/job/128700322380?pr=3244)
❌ [jmh /
summary](https://github.com/apache/groovy/actions/runs/42470637070/job/128700435249?pr=3244)
❌ [jmh / test \(bench,
\\\\.bench\\\\.\)](https://github.com/apache/groovy/actions/runs/42470637070/job/128700321697?pr=3244)
❌ [jmh / test \(core-ag,
\\\\.perf\\\\.[A-G]\)](https://github.com/apache/groovy/actions/runs/42470637070/job/128700321950?pr=3244)
❌ [jmh / test \(core-hz,
\\\\.perf\\\\.[H-Z]\)](https://github.com/apache/groovy/actions/runs/42470637070/job/128700321877?pr=3244)
❌ [jmh / test \(grails-ad,
\\\\.perf\\\\.grails\\\\.[A-D]\)](https://github.com/apache/groovy/actions/runs/42470637070/job/128700322016?pr=3244)
❌ [jmh / test \(grails-ez,
\\\\.perf\\\\.grails\\\\.[E-Z]\)](https://github.com/apache/groovy/actions/runs/42470637070/job/128700322038?pr=3244)
❌ [jmh-classic / test \(bench,
\\\\.bench\\\\.\)](https://github.com/apache/groovy/actions/runs/42470637132/job/128700321872?pr=3244)
❌ [jmh-classic / test \(core-ag,
\\\\.perf\\\\.[A-G]\)](https://github.com/apache/groovy/actions/runs/42470637132/job/128700322092?pr=3244)
❌ [jmh-classic / test \(grails-ad,
\\\\.perf\\\\.grails\\\\.[A-D]\)](https://github.com/apache/groovy/actions/runs/42470637132/job/128700322238?pr=3244)
❌ [jmh-classic / test \(grails-ez,
\\\\.perf\\\\.grails\\\\.[E-Z]\)](https://github.com/apache/groovy/actions/runs/42470637132/job/128700322088?pr=3244)
🏷️ Commit: e58dc69004fd57c661c579d53a4fb8f08aaca9a4
▶️ Tests: 897 executed
🟡 Checks: 22/25 completed
### Rerun Controls
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> 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)