Add "Suspicious collection reassignment" inspection #KT-20626 Fixed

This commit is contained in:
Mikhail Glukhikh
2018-11-29 16:23:00 +03:00
parent 3e936f64bf
commit c560aada3d
68 changed files with 1201 additions and 0 deletions
@@ -0,0 +1,12 @@
// "Join with initializer" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Replace overloaded operator with function call
// ACTION: Replace with ordinary assignment
// WITH_RUNTIME
fun test(otherList: List<Int>) {
var list: List<Int>
list = createList()
list <caret>+= otherList
}
fun createList(): List<Int> = listOf(1, 2, 3)
@@ -0,0 +1,15 @@
// "Join with initializer" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Replace overloaded operator with function call
// ACTION: Replace with ordinary assignment
// WITH_RUNTIME
class Test {
var list = createList()
fun test(otherList: List<Int>) {
// comment
list <caret>+= otherList
}
fun createList(): List<Int> = listOf(1, 2, 3)
}
@@ -0,0 +1,10 @@
// "Join with initializer" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: List<Int>) {
var list = createList()
// comment
list <caret>+= otherList
}
fun createList(): List<Int> = listOf(1, 2, 3)
@@ -0,0 +1,9 @@
// "Join with initializer" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: List<Int>) {
var list = createList() + otherList<caret>
// comment
}
fun createList(): List<Int> = listOf(1, 2, 3)
@@ -0,0 +1,15 @@
// "Join with initializer" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
// ACTION: Replace with ordinary assignment
// WITH_RUNTIME
fun test(otherList: List<Int>) {
var list = createList()
foo(list)
list <caret>+= otherList
}
fun createList(): List<Int> = listOf(1, 2, 3)
fun foo(list: List<Int>) {}