Sebastian Krajewski
04/19/2019, 6:57 PMCause: Label wasn't found during iterating through instructions
Element is unknownThe root cause was thrown at: LabelNormalizationMethodTransformer.kt:148
class foo(var bar : String)
fun main() {
var baz : foo? = foo("test")
baz?.bar += "test"
}
streetsofboston
04/19/2019, 7:03 PMnull
property…?
baz?.bar
could be null. Then you may wind up with null += test
.
This should not compile. But instead of a compiler error you get a compiler crash…Sebastian Krajewski
04/19/2019, 7:07 PMstreetsofboston
04/19/2019, 7:08 PMbaz?.let { it.bar += test }
class Container(
var value : String = ""
)
fun bug() {
val container : Container? = null
container?.value += "2"
}
It seems to come from the +=
operator with an optional/nullable left-hand side expressionSebastian Krajewski
04/19/2019, 7:19 PM?.plus()
seems to workstreetsofboston
04/19/2019, 7:21 PMString
is a immutable class, the +=
is not a plusAssign
. It probably rewrites it a object = object + param
, which may fail….class Container(
var value : String = ""
)
fun bug() {
val container : Container? = null
container?.value = container?.value + "2"
}
You should file a bug.Sebastian Krajewski
04/19/2019, 7:24 PMstreetsofboston
04/19/2019, 7:26 PMSebastian Krajewski
04/19/2019, 7:26 PM