Convert reference to lambda: fix it works correctly when referenced function has default argument

#KT-17222 Fixed
#KT-24138 Fixed
#KT-39532
This commit is contained in:
Toshiaki Kameyama
2020-06-12 17:48:47 +09:00
committed by Roman Golyshev
parent bc34f7f7f5
commit 2fd3af73eb
8 changed files with 77 additions and 15 deletions
@@ -0,0 +1,7 @@
fun test() {
foo1(<caret>::convert2)
}
fun foo1(convert: (Int) -> Unit) {}
fun convert2(i: Int, j: Int = 0) {}
@@ -0,0 +1,7 @@
fun test() {
foo1 { convert2(it) }
}
fun foo1(convert: (Int) -> Unit) {}
fun convert2(i: Int, j: Int = 0) {}
@@ -0,0 +1,7 @@
fun test() {
foo2(<caret>::convert3)
}
fun foo2(convert: (Int, Int) -> Unit) {}
fun convert3(i: Int, j: Int, k: Int = 0) {}
@@ -0,0 +1,7 @@
fun test() {
foo2 { i, j -> convert3(i, j) }
}
fun foo2(convert: (Int, Int) -> Unit) {}
fun convert3(i: Int, j: Int, k: Int = 0) {}
@@ -0,0 +1,7 @@
fun test() {
bar(<caret>Int::foo)
}
fun Int.foo(x: Int, y: Int = 42) = x + y
fun bar(f: (Int, Int) -> Int) {}
@@ -0,0 +1,7 @@
fun test() {
bar { i, x -> i.foo(x) }
}
fun Int.foo(x: Int, y: Int = 42) = x + y
fun bar(f: (Int, Int) -> Int) {}