One more case when mapTo can be generated

This commit is contained in:
Valentin Kipyatkov
2016-04-19 19:05:43 +03:00
parent db0028c11e
commit 744186402d
3 changed files with 15 additions and 0 deletions
@@ -43,6 +43,10 @@ class AddToCollectionTransformation(
FilterToTransformation(loop, inputVariable, targetCollection, previousTransformation.effectiveCondition()) //TODO: use filterNotTo?
}
is MapTransformation -> {
MapToTransformation(loop, previousTransformation.inputVariable, targetCollection, previousTransformation.mapping)
}
is FlatMapTransformation -> {
FlatMapToTransformation(loop, previousTransformation.inputVariable, targetCollection, previousTransformation.transform)
}
+7
View File
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<Int>) {
<caret>for (s in list) {
val l = s.length
target.add(l)
}
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<Int>) {
<caret>list.mapTo(target) { it.length }
}