Add 'Change to val' quickfix for delegates without setValue

So #KT-13688 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-06-01 05:21:10 +03:00
committed by Mikhail Glukhikh
parent 3292137acb
commit 2427406a8f
7 changed files with 81 additions and 3 deletions
@@ -0,0 +1,12 @@
// "Change to val" "true"
import kotlin.reflect.KProperty
fun test() {
var foo: String by <caret>Delegate()
}
class Delegate {
operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
return ""
}
}
@@ -0,0 +1,12 @@
// "Change to val" "true"
import kotlin.reflect.KProperty
fun test() {
val foo: String by <caret>Delegate()
}
class Delegate {
operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
return ""
}
}
@@ -0,0 +1,14 @@
// "Change to val" "false"
// ACTION: Create extension function 'Delegate.getValue'
// ACTION: Create member function 'Delegate.getValue'
// ERROR: Missing 'getValue(Nothing?, KProperty<*>)' method on delegate of type 'Delegate'
import kotlin.reflect.KProperty
fun test() {
var foo: String by <caret>Delegate()
}
class Delegate {
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
}
}
@@ -0,0 +1,12 @@
// "Change to val" "false"
// ACTION: Create extension function 'Delegate.getValue', function 'Delegate.setValue'
// ACTION: Create member function 'Delegate.getValue', function 'Delegate.setValue'
// ERROR: Missing 'getValue(Nothing?, KProperty<*>)' method on delegate of type 'Delegate'
// ERROR: Missing 'setValue(Nothing?, KProperty<*>, String)' method on delegate of type 'Delegate'
import kotlin.reflect.KProperty
fun test() {
var foo: String by <caret>Delegate()
}
class Delegate