[ https://issues.apache.org/jira/browse/GROOVY-9336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-9336: -------------------------------- Fix Version/s: 2.5.16 > Shift operator used in field initial value expression causing incorrect type > conversion > --------------------------------------------------------------------------------------- > > Key: GROOVY-9336 > URL: https://issues.apache.org/jira/browse/GROOVY-9336 > Project: Groovy > Issue Type: Bug > Reporter: Eric Milles > Assignee: Eric Milles > Priority: Major > Fix For: 3.0.0-rc-3, 2.5.16 > > Time Spent: 0.5h > Remaining Estimate: 0h > > Consider the following: > {code:groovy} > class C { > public static final double D = 2 << 16 - 1 > } > {code} > User has omitted parentheses around "2 << 16" and so this is evaluated as {{2 > << (16 - 1)}}. During inline constant conversion > ({{ExpressionUtils.transformInlineConstants}}), the right side of the shift > operator is converted to a double and this results in: > {code} > java.lang.UnsupportedOperationException: Shift distance must be an integral > type, but 15.0 (java.lang.Double) was supplied > at > org.codehaus.groovy.runtime.typehandling.NumberMath.leftShift(NumberMath.java:99) > at > org.apache.groovy.ast.tools.ExpressionUtils.transformBinaryConstantExpression(ExpressionUtils.java:113) > {code} > I think that the right side of any shift operation should be converted to int > (not double in this case). -- This message was sent by Atlassian Jira (v8.20.1#820001)