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:
Alexander Udalov
2017-12-29 13:04:36 +01:00
parent 5e97517c8b
commit 907f53e539
22 changed files with 207 additions and 247 deletions
@@ -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")
}
}