KT-740: Make sure that assign and increment operations compute receiver only once:

- Array operations.
This commit is contained in:
unknown
2012-03-09 18:49:50 +04:00
parent 295b38bf32
commit beff2f9b1e
7 changed files with 90 additions and 25 deletions
@@ -0,0 +1,59 @@
package foo
var c0 = 0
var c1 = 0
var c2 = 0
class A() {
var p = 0
fun get(i : Int) : Int {
c1++
return 0
}
fun set(i : Int, value : Int) {
c2++
}
}
val a : A = A()
get() {
c0++
return $a
}
fun box() : String {
var d = a[1]
if (c0 != 1) {
return "1"
}
if (c1 != 1) {
return "2"
}
++a[1]
if (c0 != 2) {
return "3"
}
if (c1 != 2) {
return "4"
}
if (c2 != 1) {
return "5"
}
--a[1]
if (c0 != 3) {
return "6"
}
if (c1 != 3) {
return "7"
}
if (c2 != 2) {
return "8"
}
return "OK"
}
@@ -19,8 +19,4 @@ fun box() : Boolean {
return false;
}
return true
}
fun main(args : Array<String>) {
println(box())
}