[FE 1.0] Save ModuleDescriptor in CompileTimeConstant
This commit is contained in:
committed by
teamcity
parent
a4f7ed00cc
commit
d9a3dd09ea
+1
-1
@@ -1091,7 +1091,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
|||||||
expectedType: KotlinType
|
expectedType: KotlinType
|
||||||
): CompileTimeConstant<*> {
|
): CompileTimeConstant<*> {
|
||||||
if (parameters.isUnsignedNumberLiteral && !checkAccessibilityOfUnsignedTypes()) {
|
if (parameters.isUnsignedNumberLiteral && !checkAccessibilityOfUnsignedTypes()) {
|
||||||
return UnsignedErrorValueTypeConstant(value, parameters)
|
return UnsignedErrorValueTypeConstant(value, constantExpressionEvaluator.module, parameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.isUnsignedLongNumberLiteral) {
|
if (parameters.isUnsignedLongNumberLiteral) {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ interface CompileTimeConstant<out T> {
|
|||||||
|
|
||||||
val parameters: CompileTimeConstant.Parameters
|
val parameters: CompileTimeConstant.Parameters
|
||||||
|
|
||||||
|
val moduleDescriptor: ModuleDescriptor
|
||||||
|
|
||||||
fun toConstantValue(expectedType: KotlinType): ConstantValue<T>
|
fun toConstantValue(expectedType: KotlinType): ConstantValue<T>
|
||||||
|
|
||||||
fun getValue(expectedType: KotlinType): T = toConstantValue(expectedType).value
|
fun getValue(expectedType: KotlinType): T = toConstantValue(expectedType).value
|
||||||
@@ -68,15 +70,15 @@ interface CompileTimeConstant<out T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TypedCompileTimeConstant<out T>(
|
class TypedCompileTimeConstant<out T>(
|
||||||
val constantValue: ConstantValue<T>,
|
val constantValue: ConstantValue<T>,
|
||||||
module: ModuleDescriptor,
|
override val moduleDescriptor: ModuleDescriptor,
|
||||||
override val parameters: CompileTimeConstant.Parameters
|
override val parameters: CompileTimeConstant.Parameters
|
||||||
) : CompileTimeConstant<T> {
|
) : CompileTimeConstant<T> {
|
||||||
|
|
||||||
override val isError: Boolean
|
override val isError: Boolean
|
||||||
get() = constantValue is ErrorValue
|
get() = constantValue is ErrorValue
|
||||||
|
|
||||||
val type: KotlinType = constantValue.getType(module)
|
val type: KotlinType = constantValue.getType(moduleDescriptor)
|
||||||
|
|
||||||
override fun toConstantValue(expectedType: KotlinType): ConstantValue<T> = constantValue
|
override fun toConstantValue(expectedType: KotlinType): ConstantValue<T> = constantValue
|
||||||
|
|
||||||
@@ -114,6 +116,7 @@ fun hasUnsignedTypesInModuleDependencies(module: ModuleDescriptor): Boolean {
|
|||||||
|
|
||||||
class UnsignedErrorValueTypeConstant(
|
class UnsignedErrorValueTypeConstant(
|
||||||
private val value: Number,
|
private val value: Number,
|
||||||
|
override val moduleDescriptor: ModuleDescriptor,
|
||||||
override val parameters: CompileTimeConstant.Parameters
|
override val parameters: CompileTimeConstant.Parameters
|
||||||
) : CompileTimeConstant<Unit> {
|
) : CompileTimeConstant<Unit> {
|
||||||
val errorValue = ErrorValue.ErrorValueWithMessage(
|
val errorValue = ErrorValue.ErrorValueWithMessage(
|
||||||
@@ -134,7 +137,7 @@ class UnsignedErrorValueTypeConstant(
|
|||||||
|
|
||||||
class IntegerValueTypeConstant(
|
class IntegerValueTypeConstant(
|
||||||
private val value: Number,
|
private val value: Number,
|
||||||
module: ModuleDescriptor,
|
override val moduleDescriptor: ModuleDescriptor,
|
||||||
override val parameters: CompileTimeConstant.Parameters,
|
override val parameters: CompileTimeConstant.Parameters,
|
||||||
private val newInferenceEnabled: Boolean,
|
private val newInferenceEnabled: Boolean,
|
||||||
val convertedFromSigned: Boolean = false
|
val convertedFromSigned: Boolean = false
|
||||||
@@ -174,9 +177,9 @@ class IntegerValueTypeConstant(
|
|||||||
|
|
||||||
private val typeConstructor =
|
private val typeConstructor =
|
||||||
if (newInferenceEnabled) {
|
if (newInferenceEnabled) {
|
||||||
IntegerLiteralTypeConstructor(value.toLong(), module, parameters)
|
IntegerLiteralTypeConstructor(value.toLong(), moduleDescriptor, parameters)
|
||||||
} else {
|
} else {
|
||||||
IntegerValueTypeConstructor(value.toLong(), module, parameters)
|
IntegerValueTypeConstructor(value.toLong(), moduleDescriptor, parameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toConstantValue(expectedType: KotlinType): ConstantValue<Number> {
|
override fun toConstantValue(expectedType: KotlinType): ConstantValue<Number> {
|
||||||
|
|||||||
Reference in New Issue
Block a user