Drop redundant frames after some of exceptions in interpreter
Drop only last frame because it is pointing on function itself.
This commit is contained in:
committed by
TeamCityServer
parent
334d518aba
commit
a9abf3b9b6
+3
-1
@@ -77,8 +77,10 @@ internal fun unfoldInstruction(element: IrElement?, environment: IrInterpreterEn
|
||||
}
|
||||
|
||||
private fun unfoldFunction(function: IrSimpleFunction, environment: IrInterpreterEnvironment) {
|
||||
if (environment.callStack.getStackCount() >= environment.configuration.maxStack)
|
||||
if (environment.callStack.getStackCount() >= environment.configuration.maxStack) {
|
||||
environment.callStack.dropFrame() // current frame is pointing on function and is redundant
|
||||
return StackOverflowError().handleUserException(environment)
|
||||
}
|
||||
// SimpleInstruction with function is added in IrCall
|
||||
// It will serve as endpoint for all possible calls, there we drop frame and copy result to new one
|
||||
function.body?.let { environment.callStack.addInstruction(CompoundInstruction(it)) }
|
||||
|
||||
@@ -180,6 +180,7 @@ internal fun IrFunction?.checkCast(environment: IrInterpreterEnvironment): Boole
|
||||
|
||||
if (!actualState.isSubtypeOf(expectedType)) {
|
||||
val convertibleClassName = environment.callStack.popState().irClass.fqNameWhenAvailable
|
||||
environment.callStack.dropFrame() // current frame is pointing on function and is redundant
|
||||
ClassCastException("$convertibleClassName cannot be cast to ${expectedType.render()}").handleUserException(environment)
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user