KT-33211 Quickfix "add parameter" for method references should infer functional type instead of KFunction (#2664)

* "Add parameter to function" quick fix: add function type instead of KFunction for method references

#KT-33211 Fixed

* Support suspend function references
This commit is contained in:
Toshiaki Kameyama
2020-06-11 23:01:07 +09:00
committed by GitHub
parent 6e67e1e78d
commit 4d2caa8e76
12 changed files with 102 additions and 14 deletions
@@ -0,0 +1,6 @@
// "Add parameter to function 'baz'" "true"
fun baz() {}
fun foo() {
baz(fun(i: Int): String { return i.toString() }<caret>)
}
@@ -0,0 +1,6 @@
// "Add parameter to function 'baz'" "true"
fun baz(function: (Int) -> String) {}
fun foo() {
baz(fun(i: Int): String { return i.toString() }<caret>)
}
@@ -0,0 +1,8 @@
// "Add parameter to function 'baz'" "true"
fun bar(): Int = 42
fun baz() {}
fun foo() {
baz(::bar<caret>)
}
@@ -0,0 +1,8 @@
// "Add parameter to function 'baz'" "true"
fun bar(): Int = 42
fun baz(kFunction0: () -> Int) {}
fun foo() {
baz(::bar)
}
@@ -0,0 +1,6 @@
// "Add parameter to function 'baz'" "true"
fun baz() {}
fun foo() {
baz { i: Int -> i.toString() }<caret>
}
@@ -0,0 +1,6 @@
// "Add parameter to function 'baz'" "true"
fun baz(function: (Int) -> String) {}
fun foo() {
baz { i: Int -> i.toString() }<caret>
}
@@ -0,0 +1,8 @@
// "Add parameter to function 'baz'" "true"
suspend fun bar(): Int = 42
suspend fun baz() {}
suspend fun foo() {
baz(::bar<caret>)
}
@@ -0,0 +1,8 @@
// "Add parameter to function 'baz'" "true"
suspend fun bar(): Int = 42
suspend fun baz(kSuspendFunction0: suspend () -> Int) {}
suspend fun foo() {
baz(::bar)
}