[IR] Report error from IR interpreter on field recursive initialization

#KT-59890
#KT-61802 Fixed
This commit is contained in:
Ivan Kylchik
2023-09-12 18:17:27 +02:00
committed by Space Team
parent 98b3bdb175
commit 2df5b48474
5 changed files with 37 additions and 1 deletions
@@ -14,7 +14,10 @@ import org.jetbrains.kotlin.ir.interpreter.fqName
import org.jetbrains.kotlin.ir.interpreter.isAccessToNotNullableObject
import org.jetbrains.kotlin.ir.interpreter.preprocessor.IrInterpreterKCallableNamePreprocessor.Companion.isEnumName
import org.jetbrains.kotlin.ir.interpreter.preprocessor.IrInterpreterKCallableNamePreprocessor.Companion.isKCallableNameCall
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.classifierOrNull
import org.jetbrains.kotlin.ir.types.isAny
import org.jetbrains.kotlin.ir.types.isPrimitiveType
import org.jetbrains.kotlin.ir.types.isStringClassType
import org.jetbrains.kotlin.ir.util.fileOrNull
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.ir.util.statements
@@ -180,6 +183,9 @@ class IrInterpreterCommonChecker : IrInterpreterChecker {
(owner.type.isPrimitiveType() || owner.type.isStringClassType())
}
// We allow recursion access, but it will fail during interpretation. This way it is easier to implement error reporting.
if (visitedStack.contains(owner)) return true
return owner.asVisited {
when {
// TODO fix later; used it here because java boolean resolves very strange,