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

Saravanan commented on GROOVY-11614:
------------------------------------

Hi Paul, I am still seeing this error on 5.0.0.beta.1

Not sure if this is specific to some condition
{code:java}
public class RecordTesting {
    public enum Thing{
        ME,
        YOU
    };

    public String create(Thing a) {

        switch (a) {
            case ME: return "STR"; break;
            case YOU: return "YOU"; break;
        }

        return ""
    }
}{code}
 

Causes a compile error (I am using @CompileStatic)
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
testdata/plugins/records/RecordTesting.java: -1: Access to 
com.Records.RecordTesting#ME is forbidden @ line -1, column -1.
testdata/plugins/records/RecordTesting.java: -1: Access to 
com.Records.RecordTesting#YOU is forbidden @ line -1, column -1.
2 errors
 {code}

> 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, 5.0.0-alpha-12
>            Reporter: Saravanan
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 5.0.0-beta-1, 4.0.27
>
>
> 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)

Reply via email to