You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2019/11/18 16:40:00 UTC

[jira] [Commented] (GROOVY-9253) Comparison between Enum and other objects should fail

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

Eric Milles commented on GROOVY-9253:
-------------------------------------

The error in Java for this is "Incompatible operand types LHSType and RHSType".

> Comparison between Enum and other objects should fail
> -----------------------------------------------------
>
>                 Key: GROOVY-9253
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9253
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Xiaoguang Wang
>            Priority: Major
>
> In Java, comparison between Enum and other objects always triggers an error when compiling.
> Groovy can follow the same behavior (at least in {{@CompileStatic}} mode) to keep consistency.
>  
> {code:java}
> package com.company.test
> import groovy.transform.CompileStatic
> @CompileStatic
> class TestEnumGroovy {
>     enum E {
>         a,b
>     }
>     static void main(String[] args) {
>         E x = E.a
>         String s = "A"
>         System.out.print(x == s)  // it causes an error in Java. But Groovy doesn't see the error.
>     }
> }
> {code}



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