Add "Suspicious collection reassignment" inspection #KT-20626 Fixed
This commit is contained in:
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
// ERROR: Type mismatch: inferred type is List<Any> but List<String> was expected
|
||||
fun test() {
|
||||
var list = listOf("")
|
||||
list <caret>+= 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: none
|
||||
fun test() {
|
||||
var i = 1
|
||||
i <caret>+= 2
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
var list = listOf(1)
|
||||
list <caret>- 1
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// ERROR: Assignment operators ambiguity: <br>public operator fun <T> Collection<Int>.plus(element: Int): List<Int> defined in kotlin.collections<br>@InlineOnly public inline operator fun <T> MutableCollection<in Int>.plusAssign(element: Int): Unit defined in kotlin.collections
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
var list = mutableListOf(1)
|
||||
list <caret>+= 2
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// ERROR: Assignment operators ambiguity: <br>public operator fun <K, V> Map<out Int, Int>.plus(pair: Pair<Int, Int>): Map<Int, Int> defined in kotlin.collections<br>@InlineOnly public inline operator fun <K, V> MutableMap<in Int, in Int>.plusAssign(pair: Pair<Int, Int>): Unit defined in kotlin.collections
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
var map = mutableMapOf(1 to 2)
|
||||
map <caret>+= 3 to 4
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// ERROR: Assignment operators ambiguity: <br>public operator fun <T> Set<Int>.plus(element: Int): Set<Int> defined in kotlin.collections<br>@InlineOnly public inline operator fun <T> MutableCollection<in Int>.plusAssign(element: Int): Unit defined in kotlin.collections
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
var set = mutableSetOf(1)
|
||||
set <caret>+= 2
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
var list = listOf(1)
|
||||
list <caret>+ 2
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// FIX: Change type to mutable
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
var list = listOf(1)
|
||||
list +=<caret> 2
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// FIX: Change type to mutable
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val list = mutableListOf(1)<caret>
|
||||
list += 2
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val list = mutableListOf(1)
|
||||
list <caret>+= 2
|
||||
}
|
||||
Reference in New Issue
Block a user