rnett
05/17/2020, 10:21 PMinit
blocks and class methods, references to the property's accessors seem to be replaced with the backing field. Ex:
class Test(@Watch var x: Int){
fun print(){
println("Prop: $x")
}
}
fun main() {
val t = Test(3)
println(t.x)
t.print()
}
The println(t.x)
works fine and prints 3, but the println
in print
prints the backing field. I'm using 1.4-M1. Ideas? I've dumped the IR and there doesn't seem to be any differencesrnett
05/17/2020, 10:25 PMprint
method:
FUN name:print visibility:public modality:FINAL <> ($this:com.rnett.klairvoyant.Test) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:com.rnett.klairvoyant.Test
BLOCK_BODY
CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in <http://kotlin.io|kotlin.io>' type=kotlin.Unit origin=null
message: STRING_CONCATENATION type=kotlin.String
CONST String type=kotlin.String value="Prop: "
CALL 'public final fun <get-x> (): @[Watched] <http://kotlin.Int|kotlin.Int> declared in com.rnett.klairvoyant.Test' type=@[Watched] <http://kotlin.Int|kotlin.Int> origin=null
$this: GET_VAR '<this>: com.rnett.klairvoyant.Test declared in com.rnett.klairvoyant.Test.print' type=com.rnett.klairvoyant.Test origin=null
And the non-method println
call:
CALL 'public final fun println (message: <http://kotlin.Int|kotlin.Int>): kotlin.Unit [inline] declared in <http://kotlin.io|kotlin.io>' type=kotlin.Unit origin=null
message: CALL 'public final fun <get-x> (): @[Watched] <http://kotlin.Int|kotlin.Int> declared in com.rnett.klairvoyant.Test' type=@[Watched] <http://kotlin.Int|kotlin.Int> origin=null
$this: GET_VAR 'val t: com.rnett.klairvoyant.Test [val] declared in com.rnett.klairvoyant.main' type=com.rnett.klairvoyant.Test origin=null
PHondogo
05/17/2020, 10:40 PMrnett
05/17/2020, 10:59 PMrnett
05/17/2020, 11:28 PM