Use getfield or putfield instructions for private properties instead of invokevirtual getA or setA

This commit is contained in:
Natalia.Ukhorskaya
2012-11-01 15:50:58 +04:00
parent ec255e8342
commit 481afeb914
6 changed files with 83 additions and 5 deletions
@@ -0,0 +1,52 @@
class A {
private var foo = 1
get() {
return 1
}
fun foo() {
foo = 5
foo
}
}
class B {
private val foo = 1
get
fun foo() {
foo
}
}
class C {
private var foo = 1
get
set
fun foo() {
foo = 2
foo
}
}
class D {
private var foo = 1
set(i: Int) {
foo = i + 1
}
fun foo() {
foo = 5
foo
}
}
fun box(): String {
A().foo()
B().foo()
C().foo()
D().foo()
return "OK"
}
@@ -0,0 +1,13 @@
class D {
var foo = 1
private set
fun foo() {
foo = 2
}
}
fun box(): String {
D().foo()
return "OK"
}