Introduce Variable: Allow choosing extraction scope for expressions in the lambda body
#KT-7720 Fixed
This commit is contained in:
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
class A(val a: Int)
|
||||
class B(val b: Int)
|
||||
|
||||
fun foo(f: A.() -> Int) = A(1).f()
|
||||
fun bar(f: B.() -> Int) = B(2).f()
|
||||
|
||||
fun test() {
|
||||
foo { bar { <selection>a</selection> + b } }
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class A(val a: Int)
|
||||
class B(val b: Int)
|
||||
|
||||
fun foo(f: A.() -> Int) = A(1).f()
|
||||
fun bar(f: B.() -> Int) = B(2).f()
|
||||
|
||||
fun test() {
|
||||
foo { val a1 = a
|
||||
bar { a1 + b } }
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
class A(val a: Int)
|
||||
class B(val b: Int)
|
||||
|
||||
fun foo(f: A.() -> Int) = A(1).f()
|
||||
fun bar(f: B.() -> Int) = B(2).f()
|
||||
|
||||
fun test() {
|
||||
foo { bar { a + <selection>b</selection> } }
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
class A(val a: Int)
|
||||
class B(val b: Int)
|
||||
|
||||
fun foo(f: A.() -> Int) = A(1).f()
|
||||
fun bar(f: B.() -> Int) = B(2).f()
|
||||
|
||||
fun test() {
|
||||
foo { bar { val b1 = b
|
||||
a + b1
|
||||
} }
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(f: () -> Int) { }
|
||||
|
||||
fun test() {
|
||||
foo(fun() = (<selection>1 + 2</selection>) * 3)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: () -> Int) { }
|
||||
|
||||
fun test() {
|
||||
val i = 1 + 2
|
||||
foo(fun() = i * 3)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(f: () -> Int) { }
|
||||
|
||||
fun test() {
|
||||
foo(fun(): Int { return (<selection>1 + 2</selection>) * 3 })
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: () -> Int) { }
|
||||
|
||||
fun test() {
|
||||
val i = 1 + 2
|
||||
foo(fun(): Int { return i * 3 })
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo(f: () -> Int) { }
|
||||
|
||||
fun test() {
|
||||
foo { (<selection>1 + 2</selection>) * 3 }
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: () -> Int) { }
|
||||
|
||||
fun test() {
|
||||
val i = 1 + 2
|
||||
foo { i * 3 }
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
foo(fun() = foo(fun() = (<selection>1 + 2</selection>) * 3))
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
val i = 1 + 2
|
||||
foo(fun() = foo(fun() = i * 3))
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
foo { foo(fun() = (<selection>1 + 2</selection>) * 3) }
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
val i = 1 + 2
|
||||
foo { foo(fun() = i * 3) }
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
foo { foo { (<selection>1 + 2</selection>) * 3 } }
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
val i = 1 + 2
|
||||
foo { foo { i * 3 } }
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
foo(fun() = foo { (<selection>1 + 2</selection>) * 3 })
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
val i = 1 + 2
|
||||
foo(fun() = foo { i * 3 })
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(f: (Int) -> Int) = f(0)
|
||||
|
||||
fun test() {
|
||||
foo { foo { (1 + 2) * <selection>it</selection> } }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun foo(f: (Int) -> Int) = f(0)
|
||||
|
||||
fun test() {
|
||||
foo { foo { val it1 = it
|
||||
(1 + 2) * it1
|
||||
} }
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(f: (Int) -> Int) = f(0)
|
||||
fun bar(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
foo { bar { (1 + 2) * <selection>it</selection> } }
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
fun foo(f: (Int) -> Int) = f(0)
|
||||
fun bar(f: () -> Int) = f()
|
||||
|
||||
fun test() {
|
||||
foo { val it1 = it
|
||||
bar { (1 + 2) * it1 } }
|
||||
}
|
||||
Reference in New Issue
Block a user