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
|
||||
}
|
||||
|
||||
@@ -47,13 +47,11 @@ const val b2 = <!EVALUATED: `2`!>safeClassCast("10")<!>
|
||||
const val c1 = <!EVALUATED: `1`!>unsafeClassCast<Int>()<!>
|
||||
const val c2 = <!WAS_NOT_EVALUATED: `
|
||||
Exception java.lang.ClassCastException: kotlin.Int cannot be cast to kotlin.String
|
||||
at ClassCastExceptionKt.unsafeClassCast(classCastException.kt:19)
|
||||
at ClassCastExceptionKt.<clinit>(classCastException.kt:48)`!>unsafeClassCast<String>()<!>
|
||||
|
||||
const val d1 = A<Int>().<!EVALUATED: `1`!>unsafeCast()<!>
|
||||
const val d2 = A<String>().<!WAS_NOT_EVALUATED: `
|
||||
Exception java.lang.ClassCastException: kotlin.Int cannot be cast to kotlin.String
|
||||
at ClassCastExceptionKt.A.unsafeCast(classCastException.kt:35)
|
||||
at ClassCastExceptionKt.<clinit>(classCastException.kt:51)`!>unsafeCast()<!>
|
||||
|
||||
const val stringList = getIntList<List<String>>().<!WAS_NOT_EVALUATED: `
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
fun foo(i: Int): Int = foo(i + 1)
|
||||
const val overflow = <!WAS_NOT_EVALUATED: `
|
||||
Exception java.lang.StackOverflowError
|
||||
at StackOverflowKt.foo(stackOverflow.kt:1)
|
||||
at StackOverflowKt.foo(stackOverflow.kt:2)
|
||||
at StackOverflowKt.foo(stackOverflow.kt:2)
|
||||
at StackOverflowKt.foo(stackOverflow.kt:2)
|
||||
at StackOverflowKt.foo(stackOverflow.kt:2)
|
||||
|
||||
Reference in New Issue
Block a user