From 3592c87abfee6622110240780fc3ccd6effb615d Mon Sep 17 00:00:00 2001 From: Mark Mann Date: Wed, 7 Dec 2022 10:46:49 -0800 Subject: [PATCH] Fix enumeration of empty list in KotlinLikeDumper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases where the Kotlin compiler encounters an exception, it attempts to print the contents of the file that it was compiling at the time. Sometimes the content contains symbols that aren't bound to implementations. When that happens the safe value parameters for a function are empty because none of them can be resolved, but the value parameter count is still non-zero because the function reference still has multiple params — this causes exception messages to fail with an error: ``` Exception in thread "main" java.lang.IllegalStateException: Problem with constructing exception message ``` This fixes the issue by only attempting to access the safe value parameters if the list is of the proper size. KT-54012 --- .../src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt index 45f5ce8f231..edde271bb6d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt @@ -1051,7 +1051,11 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption getValueArgument(i)?.let { p(i > 0, ",") // TODO flag to print param name - p.printWithNoIndent(valueParameters[i].name.asString() + " = ") + // If the symbol is unbound then valueArgumentsCount disagrees with + // valueParameters. + if (i < valueParameters.size) { + p.printWithNoIndent(valueParameters[i].name.asString() + " = ") + } it.accept(this@KotlinLikeDumper, data) } }