From d1f884bad9c9e857a40326edcb54dfa5544d66bd Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 24 Aug 2023 12:16:14 +0200 Subject: [PATCH] JVM IR: micro-optimization in IrType.erasedUpperBound Avoid `is` on interfaces, use classes instead. --- .../kotlin/backend/jvm/ir/JvmIrTypeUtils.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt index 17b75ea5c4c..eb86d3e8a22 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt @@ -91,13 +91,16 @@ val IrTypeParameter.erasedUpperBound: IrClass } val IrType.erasedUpperBound: IrClass - get() = - when (val classifier = classifierOrNull) { - is IrClassSymbol -> classifier.owner - is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound - is IrScriptSymbol -> classifier.owner.targetClass!!.owner - null -> if (this is IrErrorType) symbol.owner else error(render()) + get() = when (this) { + is IrSimpleType -> when (val classifier = classifier.owner) { + is IrClass -> classifier + is IrTypeParameter -> classifier.erasedUpperBound + is IrScript -> classifier.targetClass!!.owner + else -> error(render()) } + is IrErrorType -> symbol.owner + else -> error(render()) + } /** * Get the default null/0 value for the type.