introduceValue() always adds statement before except for safe call case

This commit is contained in:
Valentin Kipyatkov
2016-10-23 01:36:36 +03:00
parent 8f9f2027f2
commit 330d3a255a
15 changed files with 163 additions and 53 deletions
@@ -0,0 +1,8 @@
fun String.<caret>f(p: Int) = hashCode() * p
fun f(s: String?) {
s?.f(1)
s?.substring(1)?.f(2)
val s1 = s?.f(3)
val s2 = s?.substring(1)?.f(4)
}
@@ -0,0 +1,11 @@
fun f(s: String?) {
if (s != null) {
s.hashCode() * 1
}
val substring = s?.substring(1)
if (substring != null) {
substring.hashCode() * 2
}
val s1 = s?.let { it.hashCode() * 3 }
val s2 = s?.substring(1)?.let { it.hashCode() * 4 }
}
@@ -0,0 +1,11 @@
fun <caret>f(p1: Int, p2: Int): Int {
println(p1)
println(p2)
return p1 + p2
}
fun main(args: Array<String>) {
for (i in 1..10) {
println(f(i, i + 1))
}
}
@@ -0,0 +1,8 @@
fun main(args: Array<String>) {
for (i in 1..10) {
val p2 = i + 1
println(i)
println(p2)
println(i + p2)
}
}
@@ -0,0 +1,12 @@
fun <caret>f(p1: Int, p2: Int): Int {
println(p1)
println(p2)
return p1 + p2
}
fun foo1() = f(1, 2)
fun foo2(): Int = f(3, 4)
val v: Int
get() = f(5, 6)
@@ -0,0 +1,18 @@
fun foo1(): Int {
println(1)
println(2)
return 1 + 2
}
fun foo2(): Int {
println(3)
println(4)
return 3 + 4
}
val v: Int
get() {
println(5)
println(6)
return 5 + 6
}