Convert lambda to reference: add type parameter to outer call expression if needed

#KT-37744 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-05-25 14:09:57 +09:00
committed by Yan Zhulanow
parent a4239afcb3
commit 69a2697598
14 changed files with 179 additions and 7 deletions
@@ -0,0 +1,8 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: String, q: Long) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo {<caret> x: String, y: Long -> overloadFun(x, y) }
}
@@ -0,0 +1,8 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: String, q: Long) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo<String, Long>(::overloadFun)
}
@@ -0,0 +1,8 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: String, q: Long) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo({<caret> x: String, y: Long -> overloadFun(x, y) })
}
@@ -0,0 +1,8 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: String, q: Long) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo<String, Long>(::overloadFun)
}
@@ -0,0 +1,12 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: String, q: Long) {}
fun interface Action<T, U> {
fun bar(t: T, u: U)
}
fun <T, U> foo(a: Action<T, U>) {}
fun test() {
foo {<caret> x: String, y: Long -> overloadFun(x, y) }
}
@@ -0,0 +1,12 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: String, q: Long) {}
fun interface Action<T, U> {
fun bar(t: T, u: U)
}
fun <T, U> foo(a: Action<T, U>) {}
fun test() {
foo<String, Long>(::overloadFun)
}
@@ -0,0 +1,7 @@
fun overloadFun(p: Int, q: Long) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo {<caret> x: Int, y: Long -> overloadFun(x, y) }
}
@@ -0,0 +1,7 @@
fun overloadFun(p: Int, q: Long) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo(::overloadFun)
}
@@ -0,0 +1,8 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: Int) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo {<caret> x: Int, y: Long -> overloadFun(x, y) }
}
@@ -0,0 +1,8 @@
fun overloadFun(p: Int, q: Long) {}
fun overloadFun(p: Int) {}
fun <T, U> foo(fn: (T, U) -> Unit) {}
fun test() {
foo(::overloadFun)
}
@@ -0,0 +1,8 @@
fun overloadFun(p: Int) {}
fun overloadFun(p: String) {}
fun <T> ambiguityFun(vararg fn: (T) -> Unit) {}
fun overloadContext() {
ambiguityFun({<caret> x: String -> overloadFun(x) }, ::overloadFun)
}
@@ -0,0 +1,8 @@
fun overloadFun(p: Int) {}
fun overloadFun(p: String) {}
fun <T> ambiguityFun(vararg fn: (T) -> Unit) {}
fun overloadContext() {
ambiguityFun<String>(::overloadFun, ::overloadFun)
}