You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paulk-asert (via GitHub)" <gi...@apache.org> on 2026/10/22 00:04:00 UTC
[PR] GROOVY-12428: STC: instanceof narrowing leaks from one switch case in… [groovy]
paulk-asert opened a new pull request, #3003:
URL: https://github.com/apache/groovy/pull/3003
…to subsequent cases
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12428: STC: instanceof narrowing leaks from one switch case in… [groovy]
Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert merged PR #3003:
URL: https://github.com/apache/groovy/pull/3003
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12428: STC: instanceof narrowing leaks from one switch case in… [groovy]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #3003:
URL: https://github.com/apache/groovy/pull/3003#issuecomment-6401623735
## ✅ All tests passed ✅
🏷️ Commit: 6611aceab19955d91336a05f477e899c3296bf33
▶️ Tests: 118681 executed
⚪️ Checks: 32/32 completed
---
_Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12428: STC: instanceof narrowing leaks from one switch case in… [groovy]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
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>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12428: STC: instanceof narrowing leaks from one switch case in… [groovy]
Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on PR #3003:
URL: https://github.com/apache/groovy/pull/3003#issuecomment-6489348062
Added the suggested explicit negative test, and merged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12428: STC: instanceof narrowing leaks from one switch case in… [groovy]
Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on PR #3003:
URL: https://github.com/apache/groovy/pull/3003#issuecomment-6400964192
Thanks for the review. Taking your points in turn:
1. Narrowing a *different* variable and falling through is already covered by the
"'integer' may be entered directly" test: the body's narrowing is popped with
the case frame, and only the selector's own narrowing is carried forward.
2. Good call on the fall-through test. The private helper only looked at the last
statement, so `if (c) { ...; break } else { ...; break }` and
`try { ... } finally { break }` were treated as falling through and produced a
spurious `(String | Integer)` union at the next type label. I've replaced it
with `GeneralUtils.mayCompleteNormally`, the same flow analysis `StatementWriter`
uses to decide whether a case falls through, so STC and the bytecode now agree.
`yield` was already fine (abrupt in that analysis), as are `continue`, labelled
`break`, and a nested switch whose inner `break` does fall through.
3. Agreed, `default` is fine: GROOVY-8411 adds the declared type there, so the
union is a safe over-approximation. The existing GROOVY-10702 test still
expects `(Class | File | Object)` and passes unchanged.
4. #3002 merges cleanly with this branch; the changes are complementary.
While adding the tests I found one more gap, pre-existing but now easy to close:
falling through into a *constant* label kept the previous narrowing, so
case 'a':
assert x instanceof String
case 1:
x.toUpperCase() // compiled, but 1 enters this case directly
Only a class label refines the selector, so on fall-through the selector's
narrowing is now dropped unless the next label is a `ClassExpression`. Tests
added for the expression-form leak, the two constant-label shapes, and the
if/else-break and try/finally-break shapes. STC suite and full core `:test` green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12428: STC: instanceof narrowing leaks from one switch case in… [groovy]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #3003:
URL: https://github.com/apache/groovy/pull/3003#issuecomment-6332470654
## ✅ All tests passed ✅
🏷️ Commit: 073af4fdd2e573c4cdd506f1a8572a931561fcae
▶️ Tests: 122383 executed
⚪️ Checks: 32/32 completed
---
_Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org