public void testConstants() throws Exception { assertType("1", builtIns.getIntType()); assertType("0x1", builtIns.getIntType()); assertType("0X1", builtIns.getIntType()); assertType("0b1", builtIns.getIntType()); assertType("0B1", builtIns.getIntType()); assertType("1.toLong()", builtIns.getLongType()); assertType("1.0", builtIns.getDoubleType()); assertType("1.0.toDouble()", builtIns.getDoubleType()); assertType("0x1.fffffffffffffp1023", builtIns.getDoubleType()); assertType("1.0.toFloat()", builtIns.getFloatType()); assertType("0x1.fffffffffffffp1023.toFloat()", builtIns.getFloatType()); assertType("true", builtIns.getBooleanType()); assertType("false", builtIns.getBooleanType()); assertType("'d'", builtIns.getCharType()); assertType("\"d\"", builtIns.getStringType()); assertType("\"\"\"d\"\"\"", builtIns.getStringType()); assertType("Unit", KotlinBuiltIns.getInstance().getUnitType()); assertType("null", KotlinBuiltIns.getInstance().getNullableNothingType()); }
public static boolean shouldRecordInitializerForProperty( @NotNull VariableDescriptor variable, @NotNull KotlinType type) { if (variable.isVar() || type.isError()) return false; if (TypeUtils.acceptsNullable(type)) return true; KotlinBuiltIns builtIns = getBuiltIns(variable); return KotlinBuiltIns.isPrimitiveType(type) || KotlinTypeChecker.DEFAULT.equalTypes(builtIns.getStringType(), type) || KotlinTypeChecker.DEFAULT.equalTypes(builtIns.getNumber().getDefaultType(), type) || KotlinTypeChecker.DEFAULT.equalTypes(builtIns.getAnyType(), type); }