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

Björn Kautler commented on GROOVY-12300:
----------------------------------------

Ah, yes, nice, in 6 it works. 👌

> 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