[
https://issues.apache.org/jira/browse/GROOVY-12428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18130084#comment-18130084
]
ASF GitHub Bot commented on GROOVY-12428:
-----------------------------------------
codecov-commenter commented on PR #3003:
URL: https://github.com/apache/groovy/pull/3003#issuecomment-6330585454
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3003?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 72.4370%. Comparing base
([`8778bce`](https://app.codecov.io/gh/apache/groovy/commit/8778bce1a0da05b5bffe27f02819262c849f9d56?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`073af4f`](https://app.codecov.io/gh/apache/groovy/commit/073af4fdd2e573c4cdd506f1a8572a931561fcae?dropdown=coverage&el=desc&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/3003?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3003 +/- ##
==================================================
+ Coverage 72.4290% 72.4370% +0.0080%
- Complexity 40622 40629 +7
==================================================
Files 1643 1643
Lines 142686 142695 +9
Branches 26799 26801 +2
==================================================
+ Hits 103346 103364 +18
+ Misses 29830 29826 -4
+ Partials 9510 9505 -5
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3003?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/3003?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.2261% <100.0000%> (+0.0269%)` | :arrow_up: |
... and [12 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3003/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>
> STC: instanceof narrowing leaks from one switch case into subsequent cases
> --------------------------------------------------------------------------
>
> Key: GROOVY-12428
> URL: https://issues.apache.org/jira/browse/GROOVY-12428
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 5.0.3, 5.1.3, 6.0.0
> Reporter: Jochen Kemnade
> Priority: Major
> Labels: patch, patch-available
> Attachments:
> 0001-GROOVY-12428-STC-flow-typing-narrowing-leaks-from-on.patch
>
>
> h3. Reproducer 1
> {code:groovy}
> import groovy.transform.CompileStatic
> @CompileStatic
> void check(String type, Object value) {
> switch (type) {
> case 'text':
> assert value instanceof String
> break
> case 'integer':
> assert value instanceof Integer
> break
> case 'boolean':
> assert value instanceof Boolean
> break
> }
> }
> check('integer', 42)
> {code}
> With Groovy 6.0.0 this fails to compile:
> {noformat}
> Incompatible instanceof types: java.lang.String and java.lang.Integer
> @ line 10, column 20.
> Incompatible instanceof types: java.lang.String and java.lang.Boolean
> @ line 13, column 20.
> {noformat}
> h3. Reproducer 2
> {code:groovy}
> import groovy.transform.CompileStatic
> @CompileStatic
> void check(String type, Object value) {
> switch (type) {
> case 'text':
> assert value instanceof String
> break
> case 'integer':
> println value.toUpperCase()
> break
> }
> }
> check('integer', 42)
> {code}
> With Groovy 5.0.3, 5.1.3, and 6.0.0 this compiles and fails at runtime:
> {noformat}
> java.lang.ClassCastException: class java.lang.Integer cannot be cast to class
> java.lang.String
> {noformat}
> h3. Expected result
> Each case ends with {{{}break{}}}, so the narrowing of {{value}} to
> {{String}} in the first case should not apply to the other cases. Reproducer
> 1 should compile. Reproducer 2 should be rejected with "Cannot find matching
> method java.lang.Object#toUpperCase()".
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)