IR: workaround exceptions in IrElement.dump

Fallback to IrElement.render if exception happens in DumpIrTreeVisitor
(due, for example, to invalid IR structure).
This commit is contained in:
Alexander Udalov
2019-12-18 12:23:31 +01:00
parent c3d5a88e52
commit 86996bf546
@@ -28,9 +28,13 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.utils.Printer
fun IrElement.dump(normalizeNames: Boolean = false): String =
StringBuilder().also { sb ->
accept(DumpIrTreeVisitor(sb, normalizeNames), "")
}.toString()
try {
StringBuilder().also { sb ->
accept(DumpIrTreeVisitor(sb, normalizeNames), "")
}.toString()
} catch (e: Exception) {
"(Full dump is not available: ${e.message})\n" + render()
}
fun IrFile.dumpTreesFromLineNumber(lineNumber: Int, normalizeNames: Boolean = false): String {
val sb = StringBuilder()