Prohibiting incorrect transformations of loops with expression-embedded break or continue + allowed "?: continue" pattern for mapNotNull

This commit is contained in:
Valentin Kipyatkov
2016-04-22 11:35:13 +03:00
parent cfc82c55c7
commit a6132c7db9
14 changed files with 195 additions and 7 deletions
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
fun foo(list: List<String?>, target: MutableList<String>) {
<caret>list
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
.mapTo(target) { it.toString() }
}