KT-15846 'Change lambda expression return type' quick fix does nothing (#3182)

* Change parameter type quickfix: fix it works correctly on property delegate

#KT-15846 Fixed

* Change parameter type quickfix: fix it works correctly when function literal has trailing comments

#KT-15846 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-06-11 18:07:44 +09:00
committed by GitHub
parent 5ab05e6e47
commit 957a927790
7 changed files with 74 additions and 2 deletions
@@ -0,0 +1,8 @@
// "Change parameter 'f' type of function 'foo' to '() -> Int'" "true"
fun foo(f: () -> String) {}
fun test() {
foo {
<caret>1 // comment
}
}
@@ -0,0 +1,8 @@
// "Change parameter 'f' type of function 'foo' to '() -> Int'" "true"
fun foo(f: () -> Int) {}
fun test() {
foo {
1 // comment
}
}
@@ -0,0 +1,19 @@
// "Change parameter 'code' type of primary constructor of class 'TestDelegate' to '() -> Logger'" "true"
// WITH_RUNTIME
import kotlin.reflect.KProperty
object Test {
val logger by TestDelegate {
<caret>Logger(LoggerConfig("From delegate"))
}
}
class TestDelegate(val code: () -> LoggerConfig) {
operator fun getValue(kalGlobal: Test, property: KProperty<*>): Any {
return code.invoke()
}
}
data class LoggerConfig(val name: String)
data class Logger(val loggerConfig: LoggerConfig)
@@ -0,0 +1,19 @@
// "Change parameter 'code' type of primary constructor of class 'TestDelegate' to '() -> Logger'" "true"
// WITH_RUNTIME
import kotlin.reflect.KProperty
object Test {
val logger by TestDelegate {
Logger(LoggerConfig("From delegate"))
}
}
class TestDelegate(val code: () -> Logger) {
operator fun getValue(kalGlobal: Test, property: KProperty<*>): Any {
return code.invoke()
}
}
data class LoggerConfig(val name: String)
data class Logger(val loggerConfig: LoggerConfig)