JVM IR: do not optimize casts for primitives in TypeOperatorLowering

#KT-48659 Fixed
This commit is contained in:
Alexander Udalov
2021-09-09 00:07:59 +02:00
parent 64827d03bc
commit 64b911ea5e
6 changed files with 51 additions and 1 deletions
@@ -100,7 +100,8 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil
)
}
}
argument.type.isSubtypeOfClass(type.erasedUpperBound.symbol) ->
// Do not optimize casts for values of primitive types because it can affect their identity and thus change behavior.
!argument.type.isPrimitiveType() && argument.type.isSubtypeOfClass(type.erasedUpperBound.symbol) ->
argument
else ->
builder.irAs(argument, type)