Introduce Variable: Convert property accessor body to block when needed

This commit is contained in:
Alexey Sedunov
2014-12-22 19:22:06 +03:00
parent 05a0481efa
commit 82579f489b
6 changed files with 40 additions and 8 deletions
@@ -0,0 +1 @@
val x: Int get() = <selection>1</selection>
@@ -0,0 +1,4 @@
val x: Int get() {
val i = 1
return i
}
@@ -0,0 +1,8 @@
val a = 2
val x: Int get() =
if (a > 1) {
(<selection>a + 1</selection>) * (a - 1)
} else {
a * (a + 1)
}
@@ -0,0 +1,10 @@
val a = 2
val x: Int get() {
val i = a + 1
return if (a > 1) {
i * (a - 1)
} else {
a * i
}
}