Fix enumeration of empty list in KotlinLikeDumper

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
This commit is contained in:
Mark Mann
2022-12-07 10:46:49 -08:00
committed by GitHub
parent 9edaebf235
commit 3592c87abf
@@ -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)
}
}