[IR] Render different quotes depending on IR constant type
This is needed for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic message, but also seems to be good improvement for IR dumps in tests. ^KT-62559
This commit is contained in:
committed by
Space Team
parent
8f6b6e17be
commit
5cf33c3556
@@ -871,9 +871,7 @@ private fun StringBuilder.renderAsAnnotationArgument(irElement: IrElement?, rend
|
||||
null -> append("<null>")
|
||||
is IrConstructorCall -> renderAsAnnotation(irElement, renderer, options)
|
||||
is IrConst<*> -> {
|
||||
append('\'')
|
||||
append(irElement.value.toString())
|
||||
append('\'')
|
||||
renderIrConstAsAnnotationArgument(irElement)
|
||||
}
|
||||
is IrVararg -> {
|
||||
appendIterableWith(irElement.elements, prefix = "[", postfix = "]", separator = ", ") {
|
||||
@@ -888,6 +886,17 @@ private fun StringBuilder.renderAsAnnotationArgument(irElement: IrElement?, rend
|
||||
}
|
||||
}
|
||||
|
||||
private fun StringBuilder.renderIrConstAsAnnotationArgument(const: IrConst<*>) {
|
||||
val quotes = when (const.kind) {
|
||||
IrConstKind.String -> "\""
|
||||
IrConstKind.Char -> "'"
|
||||
else -> ""
|
||||
}
|
||||
append(quotes)
|
||||
append(const.value.toString())
|
||||
append(quotes)
|
||||
}
|
||||
|
||||
private fun renderClassWithRenderer(declaration: IrClass, renderer: RenderIrElementVisitor?, options: DumpIrTreeOptions) =
|
||||
declaration.runTrimEnd {
|
||||
"CLASS ${renderOriginIfNonTrivial()}" +
|
||||
|
||||
Reference in New Issue
Block a user