Don't highlight "replace with +=" for read-only collections

Related to KT-20626
This commit is contained in:
Mikhail Glukhikh
2018-12-04 12:39:25 +03:00
parent c560aada3d
commit ed8305995e
7 changed files with 63 additions and 3 deletions
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// HIGHLIGHT: INFORMATION
fun foo() {
var list = listOf(1, 2, 3)
// Should not be highlighted because it's the way we use to say explicitly
// "yes, we want to re-assign this immutable list"
list <caret>= list + 4
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// HIGHLIGHT: INFORMATION
fun foo() {
var list = listOf(1, 2, 3)
// Should not be highlighted because it's the way we use to say explicitly
// "yes, we want to re-assign this immutable list"
list += 4
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
fun foo() {
val list = mutableListOf(1, 2, 3)
list <caret>= list + 4
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
fun foo() {
val list = mutableListOf(1, 2, 3)
list += 4
}