[
https://issues.apache.org/jira/browse/GROOVY-12255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18104595#comment-18104595
]
ASF GitHub Bot commented on GROOVY-12255:
-----------------------------------------
codecov-commenter commented on PR #2784:
URL: https://github.com/apache/groovy/pull/2784#issuecomment-5284607921
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2784?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:x: Patch coverage is `75.68345%` with `169 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 70.1354%. Comparing base
([`ad907ac`](https://app.codecov.io/gh/apache/groovy/commit/ad907ac2ac33e6c1382fcf0aa9904170adf20509?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`11215d6`](https://app.codecov.io/gh/apache/groovy/commit/11215d66c725efdc5ff7308d67763b0b0e65dade?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2784?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Patch % | Lines |
|---|---|---|
|
[...us/groovy/classgen/asm/SwitchExpressionWriter.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FSwitchExpressionWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9Td2l0Y2hFeHByZXNzaW9uV3JpdGVyLmphdmE=)
| 80.8176% | [21 Missing and 40 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2784?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)
| 70.7692% | [8 Missing and 11 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...vy/groovy/console/ui/AstNodeToScriptAdapter.groovy](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=subprojects%2Fgroovy-console%2Fsrc%2Fmain%2Fgroovy%2Fgroovy%2Fconsole%2Fui%2FAstNodeToScriptAdapter.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnNvbGUvc3JjL21haW4vZ3Jvb3Z5L2dyb292eS9jb25zb2xlL3VpL0FzdE5vZGVUb1NjcmlwdEFkYXB0ZXIuZ3Jvb3Z5)
| 0.0000% | [18 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...roovy/control/customizers/SecureASTCustomizer.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fcontrol%2Fcustomizers%2FSecureASTCustomizer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NvbnRyb2wvY3VzdG9taXplcnMvU2VjdXJlQVNUQ3VzdG9taXplci5qYXZh)
| 0.0000% | [10 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...org/codehaus/groovy/ast/expr/SwitchExpression.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2Fexpr%2FSwitchExpression.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9leHByL1N3aXRjaEV4cHJlc3Npb24uamF2YQ==)
| 81.6326% | [9 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...ava/org/codehaus/groovy/ast/GroovyCodeVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FGroovyCodeVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9Hcm9vdnlDb2RlVmlzaXRvci5qYXZh)
| 0.0000% | [8 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...oovy/macro/matcher/ContextualClassCodeVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=subprojects%2Fgroovy-macro%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fcodehaus%2Fgroovy%2Fmacro%2Fmatcher%2FContextualClassCodeVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LW1hY3JvL3NyYy9tYWluL2dyb292eS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L21hY3JvL21hdGNoZXIvQ29udGV4dHVhbENsYXNzQ29kZVZpc2l0b3IuamF2YQ==)
| 0.0000% | [8 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAstBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0FzdEJ1aWxkZXIuamF2YQ==)
| 84.2105% | [5 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...y/org/codehaus/groovy/macro/matcher/ASTFinder.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=subprojects%2Fgroovy-macro%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fcodehaus%2Fgroovy%2Fmacro%2Fmatcher%2FASTFinder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LW1hY3JvL3NyYy9tYWluL2dyb292eS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L21hY3JvL21hdGNoZXIvQVNURmluZGVyLmphdmE=)
| 0.0000% | [6 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...odehaus/groovy/classgen/FinalVariableAnalyzer.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FFinalVariableAnalyzer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL0ZpbmFsVmFyaWFibGVBbmFseXplci5qYXZh)
| 90.1961% | [1 Missing and 4 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
| ... and [9
more](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree-more&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/2784?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2784 +/- ##
==================================================
+ Coverage 70.1168% 70.1354% +0.0186%
- Complexity 35772 35929 +157
==================================================
Files 1561 1564 +3
Lines 132362 133017 +655
Branches 24331 24450 +119
==================================================
+ Hits 92808 93292 +484
- Misses 31156 31264 +108
- Partials 8398 8461 +63
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2784?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...aus/groovy/ast/ClassCodeExpressionTransformer.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FClassCodeExpressionTransformer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9DbGFzc0NvZGVFeHByZXNzaW9uVHJhbnNmb3JtZXIuamF2YQ==)
| `100.0000% <100.0000%> (ø)` | |
|
[...g/codehaus/groovy/ast/ClassCodeVisitorSupport.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FClassCodeVisitorSupport.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9DbGFzc0NvZGVWaXNpdG9yU3VwcG9ydC5qYXZh)
| `100.0000% <100.0000%> (ø)` | |
|
[...va/org/codehaus/groovy/ast/CodeVisitorSupport.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FCodeVisitorSupport.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9Db2RlVmlzaXRvclN1cHBvcnQuamF2YQ==)
| `98.0520% <100.0000%> (+0.1646%)` | :arrow_up: |
|
[...rg/codehaus/groovy/classgen/AsmClassGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FAsmClassGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL0FzbUNsYXNzR2VuZXJhdG9yLmphdmE=)
| `84.8373% <100.0000%> (+0.0563%)` | :arrow_up: |
|
[...codehaus/groovy/classgen/VariableScopeVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FVariableScopeVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL1ZhcmlhYmxlU2NvcGVWaXNpdG9yLmphdmE=)
| `94.1581% <100.0000%> (+0.0404%)` | :arrow_up: |
|
[...haus/groovy/classgen/asm/DelegatingController.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FDelegatingController.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9EZWxlZ2F0aW5nQ29udHJvbGxlci5qYXZh)
| `92.1875% <100.0000%> (+0.1240%)` | :arrow_up: |
|
[...codehaus/groovy/classgen/asm/WriterController.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FWriterController.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9Xcml0ZXJDb250cm9sbGVyLmphdmE=)
| `88.6076% <100.0000%> (+0.1461%)` | :arrow_up: |
|
[...us/groovy/transform/StaticTypesTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FStaticTypesTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9TdGF0aWNUeXBlc1RyYW5zZm9ybWF0aW9uLmphdmE=)
| `87.7193% <100.0000%> (+0.4466%)` | :arrow_up: |
|
[...roovy/transform/stc/EnumTypeCheckingExtension.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FEnumTypeCheckingExtension.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvRW51bVR5cGVDaGVja2luZ0V4dGVuc2lvbi5qYXZh)
| `83.3333% <100.0000%> (+1.5152%)` | :arrow_up: |
|
[...va/org/codehaus/groovy/ast/stmt/CaseStatement.java](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2Fstmt%2FCaseStatement.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9zdG10L0Nhc2VTdGF0ZW1lbnQuamF2YQ==)
| `93.7500% <75.0000%> (+1.4423%)` | :arrow_up: |
| ... and [18
more](https://app.codecov.io/gh/apache/groovy/pull/2784?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| |
... and [5 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2784/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>
> Compile switch expressions as first-class AST (no closure desugar)
> ------------------------------------------------------------------
>
> Key: GROOVY-12255
> URL: https://issues.apache.org/jira/browse/GROOVY-12255
> Project: Groovy
> Issue Type: Dependency upgrade
> Reporter: Daniel Sun
> Priority: Major
>
> h3. Problem
> GROOVY-9272 added switch expressions. The 4.0 implementation rewrites them in
> {{AstBuilder}} to an immediately-called closure around a switch
> {{{}statement{}}}:
> {code:groovy}
> // source
> def r = switch (x) {
> case 0, 1 -> 'a'
> default -> 'z'
> }
> // compiled as
> def r = { ->
> switch (x) {
> case 0:
> case 1: return 'a'
> default: return 'z'
> }
> }.call()
> {code}
> That is a simulation, not a JEP 361 switch expression:
> * every evaluation allocates a closure and an extra call frame
> * an unmatched selector completes with {{null}} instead of throwing
> * {{return}} / {{break}} / {{continue}} are interpreted against the
> synthetic closure, not the enclosing method
> * locals assigned in an arm are closure-shared, not method locals
> * {{@CompileStatic}} cannot emit {{tableswitch}} / {{lookupswitch}} the way
> javac does
> h3. Goal
> Compile a switch expression as a first-class {{SwitchExpression}} whose arms
> {{yield}} (or throw). Emit the result on the operand stack. Keep Groovy
> {{isCase}} matching (Class, regex, Collection, Closure). Align control flow
> and exhaustiveness with [JEP 361|https://openjdk.org/jeps/361] for both
> dynamic Groovy and {{@TypeChecked}} / {{{}@CompileStatic{}}}.
> h3. Proposed shape
> * Parser builds {{SwitchExpression}} / {{{}YieldStatement{}}}; arrow
> expressions become implicit {{{}yield{}}}. No closure wrapper.
> * Codegen: join all completing arms at one label with the value on the
> stack. When the selector and labels allow it, emit {{tableswitch}} /
> {{{}lookupswitch{}}}, the Java string-switch (hash + {{equals}} + second
> switch), or {{{}Enum.ordinal(){}}}; otherwise sequential {{{}isCase{}}}.
> * Exhaustiveness: unmatched dynamic selector throws
> {{{}IllegalStateException{}}}; a complete enum may omit {{default}}
> (synthetic {{IncompatibleClassChangeError}} if a new constant appears at
> runtime). {{@TypeChecked}} / {{@CompileStatic}} reject a provably
> non-exhaustive expression at compile time.
> * Control flow: {{return}} must not leave the enclosing method through a
> switch expression; {{yield}} must not jump through a nested closure/lambda.
> An arrow arm must {{yield}} or throw on every path.
> {code:groovy}
> int n = switch (day) {
> case MONDAY, FRIDAY -> 6
> case TUESDAY -> 7
> default -> {
> int len = day.toString().length()
> yield len
> }
> }
> {code}
> h3. Compatibility
> ||topic||4.0-5.x (closure rewrite)||after this change||
> |unmatched selector (dynamic)|{{null}}|{{IllegalStateException}}|
> |non-exhaustive under STC / CS|often accepted|compile error (unless a
> complete enum)|
> |arrow block with no {{yield}}|last expression is the closure result|compile
> error unless every path yields or throws|
> |Groovy {{isCase}} cases|works|still works (fast path only when labels are
> int / String / enum constants)|
--
This message was sent by Atlassian Jira
(v8.20.10#820010)