You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Björn Kautler (Jira)" <ji...@apache.org> on 2026/08/25 17:31:00 UTC

[jira] [Created] (GROOVY-12300) STC: Support instanceof-like flow typing for class literal switch case expressions

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)