Introduce inspection "replace map.put with assignment" #KT-21502 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
ab28bdf32f
commit
8c305a137f
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.ReplacePutWithAssignmentInspection
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
|
||||
class A {
|
||||
fun put(x: Int, y: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
A().put<caret>(1, "foo")
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
val map = mutableMapOf(42 to "foo")
|
||||
|
||||
fun foo() = map.put<caret>(60, "bar")
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(map: MutableMap<Int, String>) {
|
||||
map.put<caret>(42, "foo")
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(map: MutableMap<Int, String>) {
|
||||
map[42] = "foo"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyMap() : HashMap<String, String>() {
|
||||
init {
|
||||
this.put<caret>("foo", "bar")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyMap() : HashMap<String, String>() {
|
||||
init {
|
||||
this["foo"] = "bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
val map = mutableMapOf(42 to "foo")
|
||||
map.put<caret>(60, "bar")
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
val map = mutableMapOf(42 to "foo")
|
||||
map[60] = "bar"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
var map = mutableMapOf(42 to "foo")
|
||||
map.put<caret>(60, "bar")
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
var map = mutableMapOf(42 to "foo")
|
||||
map[60] = "bar"
|
||||
}
|
||||
Reference in New Issue
Block a user