Extract Function: Utilize pseudo-value usage for return type inference

This commit is contained in:
Alexey Sedunov
2014-05-30 13:06:06 +04:00
parent 164338d6f5
commit 1a7e6eab61
35 changed files with 494 additions and 145 deletions
@@ -0,0 +1,5 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return if (<selection>a + b > 0</selection>) 1 else if (a - b < 0) 2 else b
}
@@ -0,0 +1,9 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return if (b(a, b)) 1 else if (a - b < 0) 2 else b
}
fun b(a: Int, b: Int): Boolean {
return a + b > 0
}
@@ -0,0 +1,5 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return if (a + b > 0) 1 else <selection>if (a - b < 0) 2 else b</selection>
}
@@ -0,0 +1,9 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return if (a + b > 0) 1 else i(a, b)
}
fun i(a: Int, b: Int): Int {
return if (a - b < 0) 2 else b
}
@@ -0,0 +1,5 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return if (a + b > 0) <selection>1</selection> else if (a - b < 0) 2 else b
}
@@ -0,0 +1,9 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return if (a + b > 0) i() else if (a - b < 0) 2 else b
}
fun i(): Int {
return 1
}
@@ -0,0 +1,9 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return when (a + b) {
0 -> <selection>b</selection>
1 -> -b
else -> a - b
}
}
@@ -0,0 +1,13 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return when (a + b) {
0 -> i(b)
1 -> -b
else -> a - b
}
}
fun i(b: Int): Int {
return b
}
@@ -0,0 +1,9 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return when (a + b) {
<selection>0</selection> -> b
1 -> -b
else -> a - b
}
}
@@ -0,0 +1,13 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return when (a + b) {
i() -> b
1 -> -b
else -> a - b
}
}
fun i(): Int {
return 0
}
@@ -0,0 +1,9 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return when (<selection>a + b</selection>) {
0 -> b
1 -> -b
else -> a - b
}
}
@@ -0,0 +1,13 @@
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return when (i(a, b)) {
0 -> b
1 -> -b
else -> a - b
}
}
fun i(a: Int, b: Int): Int {
return a + b
}
@@ -0,0 +1,2 @@
// SIBLING:
fun foo(a: Int, b: Int): Int = <selection>a + b</selection>
@@ -0,0 +1,6 @@
// SIBLING:
fun foo(a: Int, b: Int): Int = i(a, b)
fun i(a: Int, b: Int): Int {
return a + b
}