Add '(byte)' and '(short)' type cast for int literals only in invocation parameters

This commit is contained in:
Dmitry Cherniachenko
2017-04-19 01:16:47 +02:00
committed by Egor.Ushakov
parent 7e1cb88fe2
commit 0a7a60fa7b
6 changed files with 43 additions and 10 deletions

View File

@@ -33,11 +33,11 @@ public @interface MoreAnnotations {
String annotatedWithEmptyArrays = "";
@MoreAnnotations(
intArray = {1, 0, 2147483647, -2147483648},
byteArray = {(byte)1, (byte)0, (byte)127, (byte)-128, (byte)-1},
byteArray = {1, 0, 127, -128, -1},
floatArray = {1.0F, 0.0F, 3.4028235E38F, 1.4E-45F, 0.0F / 0.0, 1.0F / 0.0, -1.0F / 0.0},
doubleArray = {1.0D, 0.0D, 1.7976931348623157E308D, 4.9E-324D, 0.0D / 0.0, 1.0D / 0.0, -1.0D / 0.0},
booleanArray = {true, false},
shortArray = {(short)1, (short)0, (short)32767, (short)-32768, (short)-1},
shortArray = {1, 0, 32767, -32768, -1},
longArray = {1L, 0L, 9223372036854775807L, -9223372036854775808L},
charArray = {'a', '\n', '\u0001', '\u0000', '\uffff', '\u0000'},
enumArray = {MoreAnnotations.TestEnum.FirstValue, MoreAnnotations.TestEnum.SecondValue},
@@ -73,7 +73,7 @@ public @interface MoreAnnotations {
int[] intArray() default {1, 0, 2147483647, -2147483648};
byte[] byteArray() default {(byte)1, (byte)0, (byte)127, (byte)-128, (byte)-1};
byte[] byteArray() default {1, 0, 127, -128, -1};
float[] floatArray() default {1.0F, 0.0F, 3.4028235E38F, 1.4E-45F, 0.0F / 0.0, 1.0F / 0.0, -1.0F / 0.0};
@@ -81,7 +81,7 @@ public @interface MoreAnnotations {
boolean[] booleanArray() default {true, false};
short[] shortArray() default {(short)1, (short)0, (short)32767, (short)-32768, (short)-1};
short[] shortArray() default {1, 0, 32767, -32768, -1};
long[] longArray() default {1L, 0L, 9223372036854775807L, -9223372036854775808L};

View File

@@ -50,16 +50,21 @@ public class TestPrimitives {
}
public byte getByte() {
return (byte)-128;// 56
return -128;// 56
}
public short getShort() {
return (short)-32768;// 60
return -32768;// 60
}
public int getInt() {
return 42;// 64
}
public void printNarrowed() {
this.printByte((byte)this.getInt());// 68
this.printShort((short)this.getInt());// 69
}// 70
}
class 'pkg/TestPrimitives' {
@@ -186,6 +191,16 @@ class 'pkg/TestPrimitives' {
0 60
2 60
}
method 'printNarrowed ()V' {
2 64
5 64
6 64
b 65
e 65
f 65
12 66
}
}
Lines mapping:
@@ -219,3 +234,6 @@ Lines mapping:
56 <-> 53
60 <-> 57
64 <-> 61
68 <-> 65
69 <-> 66
70 <-> 67

View File

@@ -63,4 +63,9 @@ public class TestPrimitives {
public int getInt() {
return 42;
}
public void printNarrowed() {
printByte((byte)getInt());
printShort((short)getInt());
}
}