[ https://issues.apache.org/jira/browse/GROOVY-11614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17944705#comment-17944705 ]
Paul King commented on GROOVY-11614: ------------------------------------ We can extend the current functionality (elide enum type when type checking) to switch expressions fairly easily: {code} diff --git a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java --- a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java (revision daabca58aafc64f42cf6a4679e57e66f66354889) +++ b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java (date 1744720585502) @@ -31,6 +31,7 @@ import org.codehaus.groovy.ast.InnerClassNode; import org.codehaus.groovy.ast.ModuleNode; import org.codehaus.groovy.ast.expr.Expression; +import org.codehaus.groovy.ast.expr.MethodCallExpression; import org.codehaus.groovy.ast.expr.VariableExpression; import org.codehaus.groovy.classgen.AsmClassGenerator; import org.codehaus.groovy.classgen.ClassCompletionVerifier; @@ -372,6 +373,9 @@ setSourcePosition(propertyExpression, expression); return propertyExpression; } + } else if (expression instanceof MethodCallExpression) { + expression.visit(this); + return expression; } return expression; } {code} It might be an expensive operation though. It might be better to place a marker on switch expressions at the point of creation: https://github.com/apache/groovy/blob/master/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java#L983 And do the visit only when we find the marker. > Enums in switch/case statements that are not fully qualified will cause a > groovy compile error but Java requires enums to "not" be fully qualified > -------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: GROOVY-11614 > URL: https://issues.apache.org/jira/browse/GROOVY-11614 > Project: Groovy > Issue Type: Bug > Components: Compiler > Affects Versions: 4.0.24 > Reporter: Saravanan > Priority: Minor > > This is a difference in Java vs Groovy behaviour. Enums must be fully > qualified in Groovy while Java requires them to not be fully qualified. > -This was supposedly fixed, but does not seem to work in 4.0.24. Not sure > where it broke.- > Example: > {code:groovy} > void test(Thread.State ts) { > switch (ts) { > case Thread.State.NEW: // cannot remove "Thread.State." without > @CompileStatic > break > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)