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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3264?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 74.4106%. Comparing base 
([`d020012`](https://app.codecov.io/gh/apache/groovy/commit/d02001286af335c8777fb9f5770e48ec4d07119f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`e124fa5`](https://app.codecov.io/gh/apache/groovy/commit/e124fa5c8e6a70a955f45afa0766205c6081020c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 6 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3264/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/3264?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3264        +/-   ##
   ==================================================
   + Coverage     74.4010%   74.4106%   +0.0096%     
   - Complexity      44345      44371        +26     
   ==================================================
     Files            1699       1699                
     Lines          150998     151051        +53     
     Branches        28770      28783        +13     
   ==================================================
   + Hits           112344     112398        +54     
   + Misses          28380      28379         -1     
     Partials        10274      10274                
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3264?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[.../groovy/transform/RecordTypeASTTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/3264?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FRecordTypeASTTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9SZWNvcmRUeXBlQVNUVHJhbnNmb3JtYXRpb24uamF2YQ==)
 | `85.6164% <100.0000%> (+1.0804%)` | :arrow_up: |
   
   ... and [14 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3264/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>




> @IndexedProperty on a record component (or a @RecordType / @RecordBase class 
> property) generates an indexed setter setX(int, V), even though records 
> expose no setters. @Immutable classes correctly receive only the indexed 
> getter
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12730
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12730
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0
>            Reporter: Paul King
>            Priority: Major
>
> h2. Reproducer
> {code:groovy}
> import groovy.transform.*
> @RecordType
> class RecordBox {
>     @IndexedProperty List<String> items
> }
> @Immutable
> class ImmutableBox {
>     @IndexedProperty List<String> items
> }
> def setters = { Class c -> c.declaredMethods.findAll { it.name == 'setItems' 
> }*.parameterTypes*.simpleName }
> assert setters(ImmutableBox) == []
> assert setters(RecordBox) == []          // fails: [[int, String]]
> def r = new RecordBox(['a', 'b'])
> r.setItems(0, 'z')                        // compiles and runs
> assert r.items == ['a', 'b']              // fails: [z, b]
> {code}
> The behaviour is the same with and without joint compilation.
> h2. Cause
> {{IndexedPropertyASTTransformation}} omits the indexed setter when the field 
> carries {{ImmutableASTTransformation.IMMUTABLE_BREADCRUMB}}. That marker is 
> set by {{ImmutableASTTransformation.adjustPropertyForImmutability}}, but 
> {{RecordTypeASTTransformation.adjustPropertyForShallowImmutability}} makes 
> record fields final without setting it, so the indexed setter is still 
> generated.
> h2. Notes
> * Records are only shallowly immutable: the list returned by the component 
> accessor is the original (mutable) list, so the contents can already be 
> changed via {{r.items()[0] = 'z'}}. The problem is therefore one of API 
> consistency rather than a broken guarantee: a record has no setters, so it 
> should not gain an indexed one.
> * Plain classes with a {{final}} {{@IndexedProperty}} property keep their 
> indexed setter. A final reference to a mutable list is a legitimate pattern 
> and is out of scope here.
> * The joint-compilation stubber ({{IndexedPropertyASTStubber}}) omits the 
> setter for {{@RecordType}} / {{@RecordBase}} classes as of PR #3262 
> (GROOVY-12726). This change makes the compiled class agree with the stub.
> h2. Proposed fix
> Mark record properties as read-only for {{@IndexedProperty}}, either by 
> setting {{IMMUTABLE_BREADCRUMB}} in 
> {{RecordTypeASTTransformation.adjustPropertyForShallowImmutability}} or by 
> having {{IndexedPropertyASTTransformation}} recognise record classes 
> directly. Only the indexed getter is then generated, matching {{@Immutable}}.
> This removes a public method from affected classes, so it should be noted in 
> COMPATIBILITY.md and is not proposed for backporting.



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

Reply via email to