I tried to return multiple return values from a when-expression using Pair
and destructuring Declarations. This is the test code:
val (a, b) = when (s) { "def" -> Pair(false, false) "abc" -> Pair(true, true) else -> Pair(false, true) }
However, this causes a compiler error:
ERROR: Rewrite at slice SCRIPT_SCOPE key: class Line_0 old value: CODE_BLOCK@800218956 new value: CODE_BLOCK@233315297
java.lang.Throwable: Rewrite at slice SCRIPT_SCOPE key: class Line_0 old value: CODE_BLOCK@800218956 new value: CODE_BLOCK@233315297
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
at org.jetbrains.kotlin.util.slicedMap.Slices.logErrorAboutRewritingNonEqualObjects(Slices.java:158)
at org.jetbrains.kotlin.util.slicedMap.Slices.access$000(Slices.java:30)
at org.jetbrains.kotlin.util.slicedMap.Slices$1.processRewrite(Slices.java:42)
at org.jetbrains.kotlin.util.slicedMap.SlicedMapImpl.put(SlicedMapImpl.java:65)
at org.jetbrains.kotlin.resolve.DelegatingBindingTrace.record(DelegatingBindingTrace.kt:95)
[...]
ERROR: Exception while analyzing expression at (1,9) in dummy.kt
org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: Exception while analyzing expression at (1,9) in dummy.kt
This happened when trying out that test code in kotlinc-jvm
via the command line. I saw this happen with Kotlin 1.7.
Any thoughts?