1class TypePromotions { 2 3 public void byteParam(byte p1) { 4 5 } 6 7 public void shortParam(short p1) { 8 9 } 10 11 public void intParam(int p1) { 12 13 } 14 15 public void longParam(long p1) { 16 17 } 18 19 public void callingLong() { 20 longParam((byte)1); 21 longParam((short)1); 22 longParam(1); 23 longParam(1L); 24 } 25 26 public void callingInt() { 27 intParam((byte)1); 28 intParam((short)1); 29 intParam(1); 30 intParam(1L); // fails 31 } 32 33 public void callingShort() { 34 shortParam((byte)1); 35 shortParam((short)1); 36 shortParam(1); // fails 37 shortParam(1L); // fails 38 } 39 40 public void callingByte() { 41 byteParam((byte)1); 42 byteParam((short)1); // fails 43 byteParam(1); // fails 44 byteParam(1L); // fails 45 } 46 } 47 48class TypePromotionsWithExtraParam { 49 50 public void byteParam(int p0, byte p1) { 51 52 } 53 54 public void shortParam(int p0, short p1) { 55 56 } 57 58 public void intParam(int p0, int p1) { 59 60 } 61 62 public void longParam(int p0, long p1) { 63 64 } 65 66 public void callingLong() { 67 longParam(6, (byte)1); 68 longParam(6, (short)1); 69 longParam(6, 1); 70 longParam(6, 1L); 71 } 72 73 public void callingInt() { 74 intParam(6, (byte)1); 75 intParam(6, (short)1); 76 intParam(6, 1); 77 intParam(6, 1L); // fails 78 } 79 80 public void callingShort() { 81 shortParam(6, (byte)1); 82 shortParam(6, (short)1); 83 shortParam(6, 1); // fails 84 shortParam(6, 1L); // fails 85 } 86 87 public void callingByte() { 88 byteParam(6, (byte)1); 89 byteParam(6, (short)1); // fails 90 byteParam(6, 1); // fails 91 byteParam(6, 1L); // fails 92 } 93 }