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

Paul King commented on GROOVY-8380:
-----------------------------------

Right, that's correct. Please ignore the assignment example difference between 
static/dynamic above as dynamic Groovy has extra coercion going on of course. 
So, to summarise, here is what used to happen:
{code}
Long wl = 1L
long pl = 1L
assert new Integer(wl & wl) > 0  // GRE when dynamic, STC incorrectly passes
assert new Long(wl & wl) > 0     //
assert new Integer(pl & pl) > 0  // GRE when dynamic, STC detects
assert new Long(pl & pl) > 0     //
assert new Long(6 & 3) == 2L     //
assert new Long(-2 & 3) == 2L    //
{code}
Here is what happens now:
{code}
Long wl = 1L
long pl = 1L
assert new Integer(wl & wl) > 0  // GRE, STC detects
assert new Long(wl & wl) > 0     // STC incorrectly fails
assert new Integer(pl & pl) > 0  // GRE, STC detects
assert new Long(pl & pl) > 0     //
assert new Long(6 & 3) == 2L     //
assert new Long(-2 & 3) == 2L    // STC incorrectly fails
{code}
Fixing the GROOVY-8325 bug has revealed another.

The type for x & y is being correctly determined for primitives 
({{WideningCategories.isIntCategory}}) but fails for wrappers. 6 is given type 
int, -2 is given type Integer, so it also fails.


> 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