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

Paul King edited comment on GROOVY-8380 at 11/15/17 1:53 AM:
-------------------------------------------------------------

That does look wrong but unrelated. It matches what this gives:
{code}
Integer x = -1 & 3
{code}
but this is okay:
{code}
Integer x = 1 & 3
{code}
and this is okay:
{code}
int a = -1
int b = 3
int c = a & b
{code}
It seems that we match on {{NumberMathModificationInfo#or}} for primitives but 
fall back to the {{Number}} variant for wrapper types. And for whatever reason, 
constant 3 is given type {{int}} but constant -1 is given type {{Integer}}. We 
don't do that for other operators like + and *, so there is room for 
improvement there.


was (Author: paulk):
That does look wrong but unrelated. It matches what this gives:
{code}
Integer x = -1 & 3
{code}
but this is okay:
{code}
    int a = -1
    int b = 3
    int c = a & b
{code}
It seems that we match on {{NumberMathModificationInfo#or}} for primitives but 
fall back to the {{Number}} variant for wrapper types. We don't do that for 
other operators like + and *, so there is room for improvement there.

> Regression in 2.4.13 (snapshot) 62615249161b233b1827d5950671d3a83007cd9f
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-8380
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8380
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.13
>         Environment: any
>            Reporter: Patric Bechtel
>            Priority: Critical
>
> This used to work up to 2.4.12:
> {code}
> @groovy.transform.CompileStatic
> class bla {
>    static void main(String[] args) {
>       println new Long( 5 / 3 )
>    }
> }
> {code}
> starting with 2.4.13, it gives this error message:
> {noformat}
> bla.groovy: 4: [Static type checking] - Cannot find matching method 
> java.lang.Long#<init>(java.math.BigDecimal). Please check if the declared 
> type is right and if the method exists.
>  @ line 4, column 15.
>          println new Long( 5 / 3 )
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to