You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/09/01 08:30:37 UTC
[groovy] branch GROOVY_3_0_X updated: GROOVY-9704: load minus one
as long integer (port to 3_0_X)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 9695013 GROOVY-9704: load minus one as long integer (port to 3_0_X)
9695013 is described below
commit 9695013709ac54442da398b353c876ed140ee911
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Aug 31 12:01:43 2020 -0500
GROOVY-9704: load minus one as long integer (port to 3_0_X)
---
.../asm/sc/StaticTypesUnaryExpressionHelper.java | 2 +-
.../transform/stc/UnaryOperatorSTCTest.groovy | 136 +++++++++++----------
2 files changed, 73 insertions(+), 65 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java
index 51a8ed4..b1986e8 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java
@@ -67,7 +67,7 @@ public class StaticTypesUnaryExpressionHelper extends UnaryExpressionHelper impl
if (top == int_TYPE || top == short_TYPE || top == byte_TYPE || top == char_TYPE || top == long_TYPE) {
BytecodeExpression bytecodeExpression = bytecodeX(mv -> {
if (long_TYPE == top) {
- mv.visitLdcInsn(-1);
+ mv.visitLdcInsn(-1L);
mv.visitInsn(LXOR);
} else {
mv.visitInsn(ICONST_M1);
diff --git a/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy b/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy
index 9770160..e26dbfa 100644
--- a/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy
+++ b/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy
@@ -23,117 +23,125 @@ package groovy.transform.stc
*/
class UnaryOperatorSTCTest extends StaticTypeCheckingTestCase {
- void testUnaryPlusOnInt() {
- assertScript '''
+ // GROOVY-9704
+ void testBitwiseNegate_long() {
+ assertScript '''
+ long x = 1L
+ assert ~x == -2L
+ '''
+ }
+
+ void testUnaryPlusOnInt() {
+ assertScript '''
int x = 1
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnInteger() {
- assertScript '''
+ void testUnaryPlusOnInteger() {
+ assertScript '''
Integer x = new Integer(1)
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnInt() {
- assertScript '''
+ void testUnaryMinusOnInt() {
+ assertScript '''
int x = 1
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnInteger() {
- assertScript '''
+ void testUnaryMinusOnInteger() {
+ assertScript '''
Integer x = new Integer(1)
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnShort() {
- assertScript '''
+ void testUnaryPlusOnShort() {
+ assertScript '''
short x = 1
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnBoxedShort() {
- assertScript '''
+ void testUnaryPlusOnBoxedShort() {
+ assertScript '''
Short x = new Short((short)1)
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnShort() {
- assertScript '''
+ void testUnaryMinusOnShort() {
+ assertScript '''
short x = 1
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnBoxedShort() {
- assertScript '''
+ void testUnaryMinusOnBoxedShort() {
+ assertScript '''
Short x = new Short((short)1)
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnFloat() {
- assertScript '''
+ void testUnaryPlusOnFloat() {
+ assertScript '''
float x = 1f
assert +x == 1f
- '''
- }
+ '''
+ }
- void testUnaryPlusOnBoxedFloat() {
- assertScript '''
+ void testUnaryPlusOnBoxedFloat() {
+ assertScript '''
Float x = new Float(1f)
assert +x == 1f
- '''
- }
+ '''
+ }
- void testUnaryMinusOnFloat() {
- assertScript '''
+ void testUnaryMinusOnFloat() {
+ assertScript '''
float x = 1f
assert -x == -1f
- '''
- }
+ '''
+ }
- void testUnaryMinusOnBoxedFloat() {
- assertScript '''
+ void testUnaryMinusOnBoxedFloat() {
+ assertScript '''
Float x = new Float(1f)
assert -x == -1f
- '''
- }
+ '''
+ }
- void testUnaryPlusOnDouble() {
- assertScript '''
+ void testUnaryPlusOnDouble() {
+ assertScript '''
double x = 1d
assert +x == 1d
- '''
- }
+ '''
+ }
- void testUnaryPlusOnBoxedDouble() {
- assertScript '''
+ void testUnaryPlusOnBoxedDouble() {
+ assertScript '''
Double x = new Double(1d)
assert +x == 1d
- '''
- }
+ '''
+ }
- void testUnaryMinusOnDouble() {
- assertScript '''
+ void testUnaryMinusOnDouble() {
+ assertScript '''
double x = 1d
assert -x == -1d
- '''
- }
+ '''
+ }
- void testUnaryMinusOnBoxedDouble() {
- assertScript '''
+ void testUnaryMinusOnBoxedDouble() {
+ assertScript '''
Double x = new Double(1d)
assert -x == -1d
- '''
- }
+ '''
+ }
void testIntXIntInferredType() {
assertScript '''