rename
This commit is contained in:
+5
-5
@@ -81,7 +81,7 @@ public class CompileTimeConstantResolver {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return OUT_OF_RANGE;
|
return OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
if (noExpectedType(expectedType)) {
|
if (noExpectedTypeOrUnitOrError(expectedType)) {
|
||||||
if (Integer.MIN_VALUE <= value && value <= Integer.MAX_VALUE) {
|
if (Integer.MIN_VALUE <= value && value <= Integer.MAX_VALUE) {
|
||||||
return new IntValue(value.intValue());
|
return new IntValue(value.intValue());
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ public class CompileTimeConstantResolver {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CompileTimeConstant<?> getFloatValue(@NotNull String text, @NotNull JetType expectedType) {
|
public CompileTimeConstant<?> getFloatValue(@NotNull String text, @NotNull JetType expectedType) {
|
||||||
if (noExpectedType(expectedType)
|
if (noExpectedTypeOrUnitOrError(expectedType)
|
||||||
|| JetTypeChecker.INSTANCE.isSubtypeOf(builtIns.getDoubleType(), expectedType)) {
|
|| JetTypeChecker.INSTANCE.isSubtypeOf(builtIns.getDoubleType(), expectedType)) {
|
||||||
try {
|
try {
|
||||||
return new DoubleValue(Double.parseDouble(text));
|
return new DoubleValue(Double.parseDouble(text));
|
||||||
@@ -190,7 +190,7 @@ public class CompileTimeConstantResolver {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private CompileTimeConstant<?> checkNativeType(String text, JetType expectedType, String title, JetType nativeType) {
|
private CompileTimeConstant<?> checkNativeType(String text, JetType expectedType, String title, JetType nativeType) {
|
||||||
if (!noExpectedType(expectedType)
|
if (!noExpectedTypeOrUnitOrError(expectedType)
|
||||||
&& !JetTypeChecker.INSTANCE.isSubtypeOf(nativeType, expectedType)) {
|
&& !JetTypeChecker.INSTANCE.isSubtypeOf(nativeType, expectedType)) {
|
||||||
return new ErrorValue("A " + title + " literal " + text + " does not conform to the expected type " + expectedType);
|
return new ErrorValue("A " + title + " literal " + text + " does not conform to the expected type " + expectedType);
|
||||||
}
|
}
|
||||||
@@ -300,13 +300,13 @@ public class CompileTimeConstantResolver {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CompileTimeConstant<?> getNullValue(@NotNull JetType expectedType) {
|
public CompileTimeConstant<?> getNullValue(@NotNull JetType expectedType) {
|
||||||
if (noExpectedType(expectedType) || expectedType.isNullable()) {
|
if (noExpectedTypeOrUnitOrError(expectedType) || expectedType.isNullable()) {
|
||||||
return NullValue.NULL;
|
return NullValue.NULL;
|
||||||
}
|
}
|
||||||
return new ErrorValue("Null can not be a value of a non-null type " + expectedType);
|
return new ErrorValue("Null can not be a value of a non-null type " + expectedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean noExpectedType(JetType expectedType) {
|
private static boolean noExpectedTypeOrUnitOrError(JetType expectedType) {
|
||||||
return TypeUtils.noExpectedType(expectedType) || KotlinBuiltIns.getInstance().isUnit(expectedType) || ErrorUtils.isErrorType(expectedType);
|
return TypeUtils.noExpectedType(expectedType) || KotlinBuiltIns.getInstance().isUnit(expectedType) || ErrorUtils.isErrorType(expectedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user