Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0-rc-3
-
None
Description
The following code produces a VerifyError
int squarePlusOne(int num) { num ** num + 1 } assert squarePlusOne(2) == 5
The reason is that the helper power method takes a Long as first argument, but we call it with an Integer:
squarePlusOne(I)I 00000 LTestScripttestPowerShouldNotThrowVerifyError0; I : : ILOAD 1 00001 LTestScripttestPowerShouldNotThrowVerifyError0; I : I : INVOKESTATIC java/lang/Integer.valueOf (I)Ljava/lang/Integer; 00002 LTestScripttestPowerShouldNotThrowVerifyError0; I : Integer : ILOAD 1 00003 LTestScripttestPowerShouldNotThrowVerifyError0; I : Integer I : INVOKESTATIC java/lang/Integer.valueOf (I)Ljava/lang/Integer; 00004 LTestScripttestPowerShouldNotThrowVerifyError0; I : Integer Integer : INVOKESTATIC org/codehaus/groovy/runtime/DefaultGroovyMethods.power (Ljava/lang/Long;Ljava/lang/Integer;)Ljava/lang/Number; 00005 ? : ICONST_1 00006 ? : INVOKESTATIC java/lang/Integer.valueOf (I)Ljava/lang/Integer; 00007 ? : INVOKESTATIC org/codehaus/groovy/runtime/dgmimpl/NumberNumberPlus.plus (Ljava/lang/Number;Ljava/lang/Number;)Ljava/lang/Number; 00008 ? : INVOKESTATIC org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.intUnbox (Ljava/lang/Object;)I 00009 ? : IRETURN 00010 ? : LDC 0 00011 ? : IRETURN