Refactor compile constants to reduce boolean parameter hell

This commit is contained in:
Pavel V. Talanov
2015-07-03 16:04:41 +03:00
parent f97767e159
commit b0a4520710
25 changed files with 195 additions and 180 deletions
@@ -121,11 +121,12 @@ public object AnnotationSerializer {
// TODO: IntegerValueTypeConstant should not occur in annotation arguments
val number = constant.getValue(type)
val specificConstant = with(KotlinBuiltIns.getInstance()) {
val parameters = CompileTimeConstant.Parameters.ThrowException
when (type) {
getLongType() -> LongValue(number.toLong(), true, true, true)
getIntType() -> IntValue(number.toInt(), true, true, true)
getShortType() -> ShortValue(number.toShort(), true, true, true)
getByteType() -> ByteValue(number.toByte(), true, true, true)
getLongType() -> LongValue(number.toLong(), parameters)
getIntType() -> IntValue(number.toInt(), parameters)
getShortType() -> ShortValue(number.toShort(), parameters)
getByteType() -> ByteValue(number.toByte(), parameters)
else -> throw IllegalStateException("Integer constant $constant has non-integer type $type")
}
}