VarType (VarType type1, VarType type2) { if (type1.getType() == CodeConstants.TYPE_BOOLEAN && type2.getType() == CodeConstants.TYPE_BOOLEAN) { // special case booleans return type1.isFalseBoolean() ? type2 : type1; } if (type1.isSuperset(type2)) { return type2; } else if (type2.isSuperset(type1)) { return type1; } else if (type1.getTypeFamily() == type2.getTypeFamily()) { switch (type1.getTypeFamily()) { case CodeConstants.TYPE_FAMILY_INTEGER -> { if ((type1.getType() == CodeConstants.TYPE_CHAR && type2.getType() == CodeConstants.TYPE_SHORT) || (type1.getType() == CodeConstants.TYPE_SHORT && type2.getType() == CodeConstants.TYPE_CHAR)) { return VARTYPE_SHORTCHAR; } else { return VARTYPE_BYTECHAR; } } case CodeConstants.TYPE_FAMILY_OBJECT -> { return VARTYPE_NULL; } } } return null; }