Add Throwable class into interpreter builtins map

Methods of Throwable class doesn't have bodies using FIR, so they must
be handled as builtins
This commit is contained in:
Ivan Kylchik
2021-05-19 13:19:03 +03:00
committed by TeamCityServer
parent 8234c9cec1
commit e5617ede7e
2 changed files with 9 additions and 1 deletions
@@ -165,6 +165,12 @@ internal fun interpretUnaryFunction(name: String, type: String, a: Any?): Any? {
"String" -> return (a as String).length
"CharSequence" -> return (a as CharSequence).length
}
"cause" -> when (type) {
"Throwable" -> return (a as Throwable).cause
}
"message" -> when (type) {
"Throwable" -> return (a as Throwable).message
}
"size" -> when (type) {
"BooleanArray" -> return (a as BooleanArray).size
"CharArray" -> return (a as CharArray).size
@@ -186,7 +186,9 @@ private fun getOperationMap(argumentsCount: Int): MutableList<Operation> {
val operationMap = mutableListOf<Operation>()
val allPrimitiveTypes = PrimitiveType.values().map { builtIns.getBuiltInClassByFqName(it.typeFqName) }
val arrays = PrimitiveType.values().map { builtIns.getPrimitiveArrayClassDescriptor(it) } + builtIns.array
val additionalBuiltIns = listOf(builtIns.string, builtIns.any, builtIns.charSequence, builtIns.number, builtIns.comparable)
val additionalBuiltIns = listOf(
builtIns.string, builtIns.any, builtIns.charSequence, builtIns.number, builtIns.comparable, builtIns.throwable
)
fun CallableDescriptor.isFakeOverride(classDescriptor: ClassDescriptor): Boolean {
val isPrimitive = KotlinBuiltIns.isPrimitiveClass(classDescriptor) || KotlinBuiltIns.isString(classDescriptor.defaultType)