[IR] Improve dumpKotlinLike
* Generate a comment for modules. * Fix printing supertypes for classes. * Don't fail while printing constructor call if data's parent isn't IrClass
This commit is contained in:
@@ -110,6 +110,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitModuleFragment(declaration: IrModuleFragment, data: IrDeclaration?) {
|
override fun visitModuleFragment(declaration: IrModuleFragment, data: IrDeclaration?) {
|
||||||
|
p.println("// MODULE: ${declaration.name.asString()}")
|
||||||
declaration.acceptChildren(this, null)
|
declaration.acceptChildren(this, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,11 +177,18 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p.printWithNoIndent(declaration.name.asString())
|
p.printWithNoIndent(declaration.name.asString())
|
||||||
|
|
||||||
declaration.printTypeParametersWithNoIndent()
|
declaration.printTypeParametersWithNoIndent()
|
||||||
|
// TODO no test
|
||||||
if (declaration.superTypes.isNotEmpty()) {
|
if (declaration.superTypes.isNotEmpty()) {
|
||||||
for ((i, type) in declaration.superTypes.withIndex()) {
|
var first = true
|
||||||
|
for (type in declaration.superTypes) {
|
||||||
if (type.isAny()) continue
|
if (type.isAny()) continue
|
||||||
|
|
||||||
p.printWithNoIndent(if (i > 0) ", " else " : ")
|
if (!first) {
|
||||||
|
p.printWithNoIndent(", ")
|
||||||
|
} else {
|
||||||
|
p.printWithNoIndent(" : ")
|
||||||
|
first = false
|
||||||
|
}
|
||||||
|
|
||||||
type.printTypeWithNoIndent()
|
type.printTypeWithNoIndent()
|
||||||
}
|
}
|
||||||
@@ -991,8 +999,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
) {
|
) {
|
||||||
// TODO flag to omit comment block?
|
// TODO flag to omit comment block?
|
||||||
val delegatingClass = symbol.owner.parentAsClass
|
val delegatingClass = symbol.owner.parentAsClass
|
||||||
// TODO don't crash when parent isn't class
|
val currentClass = data?.parent as? IrClass
|
||||||
val currentClass = data?.parentAsClass
|
|
||||||
val delegatingClassName = delegatingClass.name.asString()
|
val delegatingClassName = delegatingClass.name.asString()
|
||||||
|
|
||||||
val name = if (data is IrConstructor) {
|
val name = if (data is IrConstructor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user