[PATCH] [Fernflower] prevent null to be cast as short/byte
This commit is contained in:
committed by
Egor Ushakov
parent
e7854376b8
commit
c241278aee
@@ -877,7 +877,7 @@ public class ExprProcessor implements CodeConstants {
|
||||
boolean quote = cast && exprent.getPrecedence() >= FunctionExprent.getPrecedence(FunctionExprent.FUNCTION_CAST);
|
||||
|
||||
// cast instead to 'byte' / 'short' when int constant is used as a value for 'Byte' / 'Short'
|
||||
if (castNarrowing && exprent.type == Exprent.EXPRENT_CONST) {
|
||||
if (castNarrowing && exprent.type == Exprent.EXPRENT_CONST && !((ConstExprent) exprent).isNull()) {
|
||||
if (leftType.equals(VarType.VARTYPE_BYTE_OBJ)) {
|
||||
leftType = VarType.VARTYPE_BYTE;
|
||||
}
|
||||
|
||||
@@ -247,6 +247,10 @@ public class ConstExprent extends Exprent {
|
||||
throw new RuntimeException("invalid constant type: " + constType);
|
||||
}
|
||||
|
||||
public boolean isNull() {
|
||||
return CodeConstants.TYPE_NULL == constType.type;
|
||||
}
|
||||
|
||||
private static String convertStringToJava(String value, boolean ascii) {
|
||||
char[] arr = value.toCharArray();
|
||||
StringBuilder buffer = new StringBuilder(arr.length);
|
||||
|
||||
Reference in New Issue
Block a user