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

Paul King edited comment on GROOVY-12300 at 8/26/26 12:16 AM:
--------------------------------------------------------------

This was also fixed in 6.0.0-alpha-1. It would be a parser change (IDE impacts) 
to backport to 5_1_X but I believe wouldn't break any existing code.

It would involve cherry-picking Eric's earlier d9c06a2c11 fix (GROOVY-9272) 
onto GROOVY_5_1_X.


was (Author: paulk):
This was also fixed in 6.0.0-alpha-1. It would be a parser change (IDE impacts) 
to backport to 5_1_X but I believe wouldn't break any existing code.

It would involve cherry-picking Eric's earlier d9c06a2c11 fix onto GROOVY_5_1_X.

> STC: Support instanceof-like flow typing for class literal switch case 
> expressions
> ----------------------------------------------------------------------------------
>
>                 Key: GROOVY-12300
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12300
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.0.3
>            Reporter: Björn Kautler
>            Priority: Major
>
> Like GROOVY-8411 for switch statements, it would be nice if the same 
> type-inference would be done for switch expressions.
> This does not compile:
> {code}
> @groovy.transform.CompileStatic
> class Foo {
>   def foo(bar) {
>     switch(bar) {
>       case RuntimeException -> bar.message
>       default -> "something else"
>     }
>   }
> }
> {code}
> while this does:
> {code}
> @groovy.transform.CompileStatic
> class Foo {
>   def foo(bar) {
>     switch(bar) {
>       case RuntimeException: return bar.message
>       default: return "something else"
>     }
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to