From 1fd12b7b8a268a08436bdab5f14dafa2b5495ce1 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Tue, 10 Nov 2020 19:54:27 +0300 Subject: [PATCH] [IR] KotlinLikeDumper: better support for enum and object accesses --- .../kotlin/ir/util/KotlinLikeDumper.kt | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/KotlinLikeDumper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/KotlinLikeDumper.kt index 6b4a5953f3307..344421edf9892 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/KotlinLikeDumper.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/KotlinLikeDumper.kt @@ -1068,9 +1068,16 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption spread.expression.accept(this, data) } - override fun visitDeclarationReference(expression: IrDeclarationReference, data: IrDeclaration?) { - // TODO support - super.visitDeclarationReference(expression, data) + override fun visitGetObjectValue(expression: IrGetObjectValue, data: IrDeclaration?) { + // TODO what if symbol is unbound? + expression.symbol.defaultType.printTypeWithNoIndent() + } + + override fun visitGetEnumValue(expression: IrGetEnumValue, data: IrDeclaration?) { + val enumEntry = expression.symbol.owner + p.printWithNoIndent(enumEntry.parentAsClass.name.asString()) + p.printWithNoIndent(".") + p.printWithNoIndent(enumEntry.name.asString()) } override fun visitRawFunctionReference(expression: IrRawFunctionReference, data: IrDeclaration?) { @@ -1080,11 +1087,6 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption super.visitRawFunctionReference(expression, data) } - override fun visitSingletonReference(expression: IrGetSingletonValue, data: IrDeclaration?) { - // TODO check - expression.type.printTypeWithNoIndent() - } - override fun visitGetValue(expression: IrGetValue, data: IrDeclaration?) { p.printWithNoIndent(expression.symbol.owner.name.asString()) } @@ -1313,16 +1315,6 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption super.visitSuspensionPoint(expression, data) } - override fun visitGetObjectValue(expression: IrGetObjectValue, data: IrDeclaration?) { - // ??? - super.visitGetObjectValue(expression, data) - } - - override fun visitGetEnumValue(expression: IrGetEnumValue, data: IrDeclaration?) { - // ??? - super.visitGetEnumValue(expression, data) - } - override fun visitFunctionReference(expression: IrFunctionReference, data: IrDeclaration?) { super.visitFunctionReference(expression, data) }