Inline: Fix operand stack type verify error
This is a proposal to fix KT-49364. Operand stack type verification happens before `checkcast` is executed. When we implicitly cast an inline class to a non-inline type, if type of stack value is not subtype of the target, then coercing is necessary.
This commit is contained in:
+7
@@ -38,6 +38,13 @@ abstract class PromisedValue(val codegen: ExpressionCodegen, val type: Type, val
|
||||
if (isFromTypeUnboxed && !isToTypeUnboxed) {
|
||||
val boxed = typeMapper.mapType(erasedSourceType, TypeMappingMode.CLASS_DECLARATION)
|
||||
StackValue.boxInlineClass(type, boxed, erasedSourceType.isNullable(), mv)
|
||||
|
||||
if (typeMapper.mapType(erasedTargetType) == target) {
|
||||
if (!erasedSourceType.isSubtypeOf(erasedTargetType, codegen.context.typeSystem)) {
|
||||
StackValue.coerce(boxed, target, mv, false)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
if (!isFromTypeUnboxed && isToTypeUnboxed) {
|
||||
|
||||
Reference in New Issue
Block a user