Add "Change type to mutable collection" quick fix for NO_SET_METHOD

#KT-29193 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-02-06 19:07:05 +09:00
committed by Mikhail Glukhikh
parent 52c2547d95
commit 4113d06767
14 changed files with 221 additions and 35 deletions
@@ -0,0 +1,6 @@
// "Change type to MutableList" "true"
// WITH_RUNTIME
fun main() {
val list = listOf(1, 2, 3)
list[1]<caret> = 10
}
@@ -0,0 +1,6 @@
// "Change type to MutableList" "true"
// WITH_RUNTIME
fun main() {
val list = mutableListOf(1, 2, 3)<caret>
list[1] = 10
}
@@ -0,0 +1,8 @@
// "Change type to MutableList" "true"
// WITH_RUNTIME
fun main() {
val list = foo()
list[1]<caret> = 10
}
fun foo() = listOf(1, 2, 3)
@@ -0,0 +1,8 @@
// "Change type to MutableList" "true"
// WITH_RUNTIME
fun main() {
val list = foo().toMutableList()<caret>
list[1] = 10
}
fun foo() = listOf(1, 2, 3)
@@ -0,0 +1,6 @@
// "Change type to MutableMap" "true"
// WITH_RUNTIME
fun main() {
val map = mapOf(1 to "a")
map[2<caret>] = "b"
}
@@ -0,0 +1,6 @@
// "Change type to MutableMap" "true"
// WITH_RUNTIME
fun main() {
val map = mutableMapOf(1 to "a")<caret>
map[2] = "b"
}
@@ -0,0 +1,8 @@
// "Change type to MutableMap" "true"
// WITH_RUNTIME
fun main() {
val map = foo()
map[2<caret>] = "b"
}
fun foo() = mapOf(1 to "a")
@@ -0,0 +1,8 @@
// "Change type to MutableMap" "true"
// WITH_RUNTIME
fun main() {
val map = foo().toMutableMap()<caret>
map[2] = "b"
}
fun foo() = mapOf(1 to "a")
@@ -0,0 +1,8 @@
// "Change type to MutableSet" "false"
// DISABLE-ERRORS
// ACTION: Replace overloaded operator with function call
// WITH_RUNTIME
fun main() {
val set = setOf(1, 2, 3)
set[1]<caret> = 10
}