Björn Kautler created GROOVY-12300:
--------------------------------------

             Summary: 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


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