groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Sun (Jira)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8444) Support unqualified enum constants in switch cases (like Java)
Date Mon, 21 Oct 2019 08:33:00 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-8444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Daniel Sun updated GROOVY-8444:
-------------------------------
    Description: 
Would it be possible to support this syntax that Java requires for enum constants in switch
statements?
{code:java}
enum SomeEnum { A, B }
void meth(SomeEnum e) {
  switch (e) {
  case A: // currently this must be qualified, like SomeEnum.A
    ...
    break
  case B:
    ...
    break
  }
}
meth(someEnumValue) // currently throws MissingPropertyException: No such property: A for
class...
{code}

P.S. As we need to check whether the switch-case is for enum, type info is required, so it
only works when STC is enabled.

  was:
Would it be possible to support this syntax that Java requires for enum constants in switch
statements?
{code:java}
enum SomeEnum { A, B }
void meth(SomeEnum e) {
  switch (e) {
  case A: // currently this must be qualified, like SomeEnum.A
    ...
    break
  case B:
    ...
    break
  }
}
meth(someEnumValue) // currently throws MissingPropertyException: No such property: A for
class...
{code}




> Support unqualified enum constants in switch cases (like Java)
> --------------------------------------------------------------
>
>                 Key: GROOVY-8444
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8444
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Eric Milles
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 3.0.0-rc-1
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Would it be possible to support this syntax that Java requires for enum constants in
switch statements?
> {code:java}
> enum SomeEnum { A, B }
> void meth(SomeEnum e) {
>   switch (e) {
>   case A: // currently this must be qualified, like SomeEnum.A
>     ...
>     break
>   case B:
>     ...
>     break
>   }
> }
> meth(someEnumValue) // currently throws MissingPropertyException: No such property: A
for class...
> {code}
> P.S. As we need to check whether the switch-case is for enum, type info is required,
so it only works when STC is enabled.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message