Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Consider the following:
class C { public static final double D = 2 << 16 - 1 }
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:
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)
I think that the right side of any shift operation should be converted to int (not double in this case).
Attachments
Issue Links
- links to