Inline Property also supported for properties with getter

This commit is contained in:
Valentin Kipyatkov
2017-05-23 10:42:57 +03:00
parent 20686297e5
commit e6bfa55534
15 changed files with 233 additions and 142 deletions
@@ -1,7 +0,0 @@
val Int.C = 239
// not implemented yet
fun f() {
println(5.<caret>C)
}
@@ -1,8 +0,0 @@
val C: Int
get() = 239
// not implemented yet
fun f() {
println(<caret>C)
}
@@ -1,9 +0,0 @@
val C = 239
get() = $C + 1
// not implemented yet
fun f() {
println(<caret>C)
}
@@ -0,0 +1,9 @@
val <caret>property: Int
get {
println("access!")
return 1
}
fun foo() {
println(property)
}
@@ -0,0 +1,4 @@
fun foo() {
println("access!")
println(1)
}
@@ -0,0 +1,8 @@
import java.util.*
val <caret>property: Int
get() = Random().nextInt()
fun foo() {
println(property)
}
@@ -0,0 +1,5 @@
import java.util.*
fun foo() {
println(Random().nextInt())
}
@@ -0,0 +1,7 @@
val String.<caret>property: Int
get() = length * 2
fun String.foo() {
println("a".property)
println(property)
}
@@ -0,0 +1,4 @@
fun String.foo() {
println("a".length * 2)
println(length * 2)
}
@@ -0,0 +1,8 @@
// ERROR: Cannot inline property with accessor(s) and backing field
val C = 239
get() = field + 1
fun f() {
println(<caret>C)
}