Refactor ConstantValue implementations
Remove KotlinBuiltIns and take a ModuleDescriptor instance in getType instead. This will allow to create constant values in contexts where there's no module or built-ins accessible (such as, deserialization of module annotations during indexing of .kotlin_module files in IDE). Note that some values (KClassValue, EnumValue, AnnotationValue) still take module-dependent objects (KotlinType, ClassDescriptor and AnnotationDescriptor respectively). This is to be refactored later
This commit is contained in:
+2
-2
@@ -207,7 +207,7 @@ class StatementGenerator(
|
||||
|
||||
fun generateConstantExpression(expression: KtExpression, constant: CompileTimeConstant<*>): IrExpression {
|
||||
val constantValue = constant.toConstantValue(getInferredTypeWithImplicitCastsOrFail(expression))
|
||||
val constantType = constantValue.type
|
||||
val constantType = constantValue.getType(context.moduleDescriptor)
|
||||
|
||||
return when (constantValue) {
|
||||
is StringValue ->
|
||||
@@ -231,7 +231,7 @@ class StatementGenerator(
|
||||
is ShortValue ->
|
||||
IrConstImpl.short(expression.startOffset, expression.endOffset, constantType, constantValue.value)
|
||||
else ->
|
||||
TODO("handle other literal types: ${constantValue.type}")
|
||||
TODO("handle other literal types: $constantType")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user