[
https://issues.apache.org/jira/browse/GROOVY-11621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945119#comment-17945119
]
ASF GitHub Bot commented on GROOVY-11621:
-----------------------------------------
codecov-commenter commented on PR #2197:
URL: https://github.com/apache/groovy/pull/2197#issuecomment-2810018087
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2197?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 68.9237%. Comparing base
[(`709d38e`)](https://app.codecov.io/gh/apache/groovy/commit/709d38e12521747fde53186820e6c680faef3d57?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
to head
[(`f8cf100`)](https://app.codecov.io/gh/apache/groovy/commit/f8cf100ddaee8a7d35f4a5ccaf91741bc635ee42?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 1 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/2197?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2197 +/- ##
==================================================
+ Coverage 68.9190% 68.9237% +0.0047%
- Complexity 29595 29597 +2
==================================================
Files 1423 1423
Lines 113896 113897 +1
Branches 19751 19752 +1
==================================================
+ Hits 78496 78502 +6
+ Misses 28781 28777 -4
+ Partials 6619 6618 -1
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2197?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/2197?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.4647% <100.0000%> (+0.0035%)` | :arrow_up: |
... and [4 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2197/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>
> Assigning null to a List or Map using bracket notation does not work with
> @CompileStatic
> ----------------------------------------------------------------------------------------
>
> Key: GROOVY-11621
> URL: https://issues.apache.org/jira/browse/GROOVY-11621
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 4.0.26
> Reporter: Per Nyfelt
> Assignee: Eric Milles
> Priority: Minor
>
> I was recently experimenting with @CompileStatic for performance improvements
> and noticed that when using the short notation of putAt to assign a null
> value I get the following compilation error
> [Static type checking] - Cannot call <T>
> org.codehaus.groovy.runtime.DefaultGroovyMethods#putAt(java.util.List<T>,
> int, T) with arguments [java.util.List<java.lang.String>, int,
> java.lang.Object]
>
> Here is an example:
> {code:groovy}
> import groovy.transform.CompileStatic
> import org.junit.jupiter.api.Test
> @CompileStatic
> class PutAtTest {
> @Test
> void testList() {
> // These all work
> def list = ['a', 'b', 'c']
> list[0] = 'aa'
> assert list[0] == 'aa'
> list.set(2, null)
> assert list[2] == null
> list.putAt(0, null)
> assert list[0] == null
> // This Fails
> list[1] = null
> assert list[1] == null : "Short notation not working when assigning null"
> }
> @Test
> void testMap() {
> // These all work
> def map = [a: 'foo', b: 'bar', c: 'baz', d: 'qui']
> map['a'] = 'aa'
> assert map['a'] == 'aa'
> map.put('c', null)
> assert map['c'] == null
> map.putAt('a', null)
> assert map['a'] == null
> map.d = null
> assert map['d'] == null
> // This Fails
> map['b'] = null
> assert map['b'] == null : "Short notation not working when assigning
> null"
> }
> }
> {code}
> As pointed out by [~paulk] on the users list, a workaround is to cast e.g.
> {code:groovy}
> list[1] = (String)null
> map['b'] = (String)null
> {code}
> But it would be groovier if assigning null using short bracket notation "just
> worked". Also note that property notation for maps works (map.d = null) but
> fails with brackets (map['d'] = null) which is surprising from a user
> perspective as they are seen as alternative but equivalent ways to do the
> same thing.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)