The new `when` thing in `1.3 RC` is reformatted in...
# announcements
r
The new
when
thing in
1.3 RC
is reformatted incorrectly by IDEA:
Copy code
val value = when (val type = peek()) {
                    JsonToken.BOOLEAN -> nextBoolean()
                    JsonToken.NULL -> nextNull().let { null }
                    else -> throw Error("Unexpected type $type")
                }
After auto-formatting:
Copy code
val value = when (
                    val type = peek()) {
                    JsonToken.BOOLEAN -> nextBoolean()
                    JsonToken.NULL -> nextNull().let { null }
                    else -> throw Error("Unexpected type $type")
                }
There is no matching option under the
when
close in
Code Style
. Is this a bug / missing feature? It happens with both the old default IDEA style and the new one.
😱 2
Wow nevermind this code doesn't compile anyway
So I found the issue on Youtrack for the formatting and upvoted it, and I am reporting my compilation issue, as I can't find anything like this already reported.
FYI here's the formatting issue https://youtrack.jetbrains.net/issue/KT-27027
g
val type = peek() is not an expression it shouldn't compile imo
val type = peek() val value = when(type){ ...
r
@gergo what are you talking about
g
val type = peek()
initializing a variable is not an expression it won't return anything, how do you want to match it's result with when?
r
Can you read at least the first 6 words in my post? We're talking Kotlin 1.3 here.
g
ohh, i see, i wan't aware of that change, sorry.
c
Where is this change to
when
documented?
k
So far, only in the 1.3-M1 blog post (https://blog.jetbrains.com/kotlin/2018/07/see-whats-coming-in-kotlin-1-3-m1/). If you're just looking at the 1.3-RC post, you won't know about it. But presumably when 1.3 actually lands, the new blog post will contain everything new in 1.3, and the docs will be updated to include a mention of this new
when
subject variable feature
👍 2