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:
@@ -28,9 +28,13 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
|||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
|
|
||||||
fun IrElement.dump(normalizeNames: Boolean = false): String =
|
fun IrElement.dump(normalizeNames: Boolean = false): String =
|
||||||
StringBuilder().also { sb ->
|
try {
|
||||||
accept(DumpIrTreeVisitor(sb, normalizeNames), "")
|
StringBuilder().also { sb ->
|
||||||
}.toString()
|
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 {
|
fun IrFile.dumpTreesFromLineNumber(lineNumber: Int, normalizeNames: Boolean = false): String {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
|
|||||||
Reference in New Issue
Block a user