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

ASF GitHub Bot commented on GROOVY-8965:
----------------------------------------

eric-milles opened a new pull request, #1742:
URL: https://github.com/apache/groovy/pull/1742

   As discussed under 8965 and 10668, check LUB type first for common method 
(fixes `testMultipleInstanceOf4`).  Duck-typing (`testMultipleInstanceOf1` and 
`testMultipleInstanceOf5`) is incomplete; currently reported as ambiguous 
method error.
   
   https://issues.apache.org/jira/browse/GROOVY-8965
   https://issues.apache.org/jira/browse/GROOVY-10180
   https://issues.apache.org/jira/browse/GROOVY-10668




> instanceof with || inserts wrong cast
> -------------------------------------
>
>                 Key: GROOVY-8965
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8965
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.5.5
>            Reporter: Daniil Ovchinnikov
>            Assignee: Eric Milles
>            Priority: Major
>
> {code:java}
> @groovy.transform.CompileStatic
> def foo(a) {
>     if (a instanceof Integer || a instanceof Double) {
>         a.floatValue() // expected: cast to Number; actual: cast to Integer
>     }
> }
> println foo(1d).class // CCE: java.lang.Double cannot be cast to 
> java.lang.Integer
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to