Prohibiting incorrect transformations of loops with expression-embedded break or continue + allowed "?: continue" pattern for mapNotNull
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'flatMap{}.mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.flatMap { it.indices }
|
||||
.mapNotNull { bar(it) }
|
||||
.mapTo(target) { it.substring(1) }
|
||||
}
|
||||
|
||||
fun bar(p: Int): String? = null
|
||||
Reference in New Issue
Block a user