Call chain --> Sequence: take termination into account

Related to KT-15476
This commit is contained in:
Toshiaki Kameyama
2018-07-02 13:20:26 +03:00
committed by Mikhail Glukhikh
parent 108dea5b46
commit 7e28cb1fe3
146 changed files with 1117 additions and 72 deletions
@@ -1,6 +1,6 @@
// WITH_RUNTIME
fun test(list: List<Int>): List<Pair<List<Int>, List<Int>>> {
fun test(list: List<Int>): List<Pair<IndexedValue<List<Int>>, IndexedValue<List<Int>>>> {
return list
.<caret>chunked(1)
.distinct()
@@ -30,6 +30,7 @@ fun test(list: List<Int>): List<Pair<List<Int>, List<Int>>> {
.take(1)
.takeWhile { true }
.windowed(1, 1, true)
.withIndex()
.zipWithNext()
.zipWithNext { a, b -> a }
}
@@ -1,6 +1,6 @@
// WITH_RUNTIME
fun test(list: List<Int>): List<Pair<List<Int>, List<Int>>> {
fun test(list: List<Int>): List<Pair<IndexedValue<List<Int>>, IndexedValue<List<Int>>>> {
return list
.asSequence()
.chunked(1)
@@ -31,6 +31,7 @@ fun test(list: List<Int>): List<Pair<List<Int>, List<Int>>> {
.take(1)
.takeWhile { true }
.windowed(1, 1, true)
.withIndex()
.zipWithNext()
.zipWithNext { a, b -> a }
.toList()
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return mutableListOf(1, 2, 3).<caret>filter { it > 1 }.map { it * 2 }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return mutableListOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.toList()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return mutableSetOf(1, 2, 3).<caret>filter { it > 1 }.map { it * 2 }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return mutableSetOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.toList()
}
@@ -2,5 +2,8 @@
// WITH_RUNTIME
fun test(list: List<Int>): List<Int> {
return list.filter { it > 2 }.dropLast(1).<caret>filter { it > 2 }
return list
.filter { it > 2 }
.dropLast(1)
.<caret>filter { it > 2 }
}
@@ -4,7 +4,6 @@
fun test(list: List<Int>): List<Int> {
return list
.reversed()
.map { it + 1 }
.<caret>map { it + 1 }
.dropLast(1)
.takeLast(2)
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return setOf(1, 2, 3).<caret>filter { it > 1 }.map { it * 2 }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return setOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.toList()
}
@@ -1,8 +0,0 @@
// WITH_RUNTIME
fun test(): Int {
return listOf(1, 2, 3)
.<caret>filter { it > 1 }
.map { it * 2 }
.sum()
}
@@ -1,9 +0,0 @@
// WITH_RUNTIME
fun test(): Int {
return listOf(1, 2, 3)
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.sum()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val all: Boolean = list.<caret>filter { it > 1 }.all { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val all: Boolean = list.asSequence().filter { it > 1 }.all { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val any: Boolean = list.<caret>filter { it > 1 }.any()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val any: Boolean = list.asSequence().filter { it > 1 }.any()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val asIterable: Iterable<Int> = list.<caret>filter { it > 1 }.asIterable()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val asIterable: Iterable<Int> = list.asSequence().filter { it > 1 }.asIterable()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val asSequence: Sequence<Int> = list.<caret>filter { it > 1 }.asSequence()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val asSequence: Sequence<Int> = list.asSequence().filter { it > 1 }.asSequence()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associate: Map<Int, Int> = list.<caret>filter { it > 1 }.associate { it to it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associate: Map<Int, Int> = list.asSequence().filter { it > 1 }.associate { it to it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associateBy: Map<Int, Int> = list.<caret>filter { it > 1 }.associateBy { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associateBy: Map<Int, Int> = list.asSequence().filter { it > 1 }.associateBy { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associateByTo = list.<caret>filter { it > 1 }.associateByTo(mutableMapOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associateByTo = list.asSequence().filter { it > 1 }.associateByTo(mutableMapOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associateTo: MutableMap<Int, Int> = list.<caret>filter { it > 1 }.associateTo(mutableMapOf()) { it to it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val associateTo: MutableMap<Int, Int> = list.asSequence().filter { it > 1 }.associateTo(mutableMapOf()) { it to it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val average: Double = list.<caret>filter { it > 1 }.average()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val average: Double = list.asSequence().filter { it > 1 }.average()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val contains: Boolean = list.<caret>filter { it > 1 }.contains(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val contains: Boolean = list.asSequence().filter { it > 1 }.contains(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val count: Int = list.<caret>filter { it > 1 }.count()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val count: Int = list.asSequence().filter { it > 1 }.count()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val elementAt = list.<caret>filter { it > 1 }.elementAt(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val elementAt = list.asSequence().filter { it > 1 }.elementAt(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val elementAtOrElse: Int = list.<caret>filter { it > 1 }.elementAtOrElse(1) { 1 }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val elementAtOrElse: Int = list.asSequence().filter { it > 1 }.elementAtOrElse(1) { 1 }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val elementAtOrNull: Int? = list.<caret>filter { it > 1 }.elementAtOrNull(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val elementAtOrNull: Int? = list.asSequence().filter { it > 1 }.elementAtOrNull(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterIndexedTo: MutableList<Int> = list.<caret>filter { it > 1 }.filterIndexedTo(mutableListOf()) { index, it -> true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }.filterIndexedTo(mutableListOf()) { index, it -> true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterIsInstanceTo = list.<caret>filter { it > 1 }.filterIsInstanceTo(mutableListOf<Int>())
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterIsInstanceTo = list.asSequence().filter { it > 1 }.filterIsInstanceTo(mutableListOf<Int>())
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterNotNullTo: MutableList<Int> = list.<caret>filter { it > 1 }.filterNotNullTo(mutableListOf())
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }.filterNotNullTo(mutableListOf())
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterNotTo: MutableList<Int> = list.<caret>filter { it > 1 }.filterNotTo(mutableListOf()) { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterNotTo: MutableList<Int> = list.asSequence().filter { it > 1 }.filterNotTo(mutableListOf()) { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterTo: MutableList<Int> = list.<caret>filter { it > 1 }.filterTo(mutableListOf()) { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterTo: MutableList<Int> = list.asSequence().filter { it > 1 }.filterTo(mutableListOf()) { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val find: Int? = list.<caret>filter { it > 1 }.find { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val find: Int? = list.asSequence().filter { it > 1 }.find { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val findLast: Int? = list.<caret>filter { it > 1 }.findLast { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val findLast: Int? = list.asSequence().filter { it > 1 }.findLast { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val first: Int = list.<caret>filter { it > 1 }.first()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val first: Int = list.asSequence().filter { it > 1 }.first()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val firstOrNull: Int? = list.<caret>filter { it > 1 }.firstOrNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val firstOrNull: Int? = list.asSequence().filter { it > 1 }.firstOrNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val fold: Int = list.<caret>filter { it > 1 }.fold(0) { acc, i -> acc + i }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val fold: Int = list.asSequence().filter { it > 1 }.fold(0) { acc, i -> acc + i }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val foldIndexed = list.<caret>filter { it > 1 }.foldIndexed(0) { index, acc, i -> acc + i }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val foldIndexed = list.asSequence().filter { it > 1 }.foldIndexed(0) { index, acc, i -> acc + i }
}
@@ -0,0 +1,6 @@
// PROBLEM: none
// WITH_RUNTIME
fun test(list: List<Int>) {
val forEach: Unit = list.<caret>filter { it > 1 }.forEach { }
}
@@ -0,0 +1,6 @@
// PROBLEM: none
// WITH_RUNTIME
fun test(list: List<Int>) {
val forEachIndexed: Unit = list.<caret>filter { it > 1 }.forEachIndexed { index, i -> }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val groupBy = list.<caret>filter { it > 1 }.groupBy { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val groupBy = list.asSequence().filter { it > 1 }.groupBy { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val groupByTo: MutableMap<Int, MutableList<Int>> = list.<caret>filter { it > 1 }.groupByTo(mutableMapOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val groupByTo: MutableMap<Int, MutableList<Int>> = list.asSequence().filter { it > 1 }.groupByTo(mutableMapOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val groupingBy: Grouping<Int, Int> = list.<caret>filter { it > 1 }.groupingBy { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val groupingBy: Grouping<Int, Int> = list.asSequence().filter { it > 1 }.groupingBy { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val indexOf: Int = list.<caret>filter { it > 1 }.indexOf(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val indexOf: Int = list.asSequence().filter { it > 1 }.indexOf(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val indexOfFirst: Int = list.<caret>filter { it > 1 }.indexOfFirst { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val indexOfFirst: Int = list.asSequence().filter { it > 1 }.indexOfFirst { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val indexOfLast: Int = list.<caret>filter { it > 1 }.indexOfLast { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val indexOfLast: Int = list.asSequence().filter { it > 1 }.indexOfLast { true }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val joinTo: StringBuilder = list.<caret>filter { it > 1 }.joinTo(StringBuilder())
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val joinTo: StringBuilder = list.asSequence().filter { it > 1 }.joinTo(StringBuilder())
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val joinToString: String = list.<caret>filter { it > 1 }.joinToString()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val joinToString: String = list.asSequence().filter { it > 1 }.joinToString()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val last: Int = list.<caret>filter { it > 1 }.last()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val last: Int = list.asSequence().filter { it > 1 }.last()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val lastIndexOf: Int = list.<caret>filter { it > 1 }.lastIndexOf(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val lastIndexOf: Int = list.asSequence().filter { it > 1 }.lastIndexOf(1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val lastOrNull = list.<caret>filter { it > 1 }.lastOrNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val lastOrNull = list.asSequence().filter { it > 1 }.lastOrNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapIndexedNotNullTo: MutableList<Int> = list.<caret>filter { it > 1 }.mapIndexedNotNullTo(mutableListOf()) { index, i -> i }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapIndexedNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }.mapIndexedNotNullTo(mutableListOf()) { index, i -> i }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapIndexedTo: MutableList<Int> = list.<caret>filter { it > 1 }.mapIndexedTo(mutableListOf()) { index, i -> i }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }.mapIndexedTo(mutableListOf()) { index, i -> i }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapNotNullTo: MutableList<Int> = list.<caret>filter { it > 1 }.mapNotNullTo(mutableListOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }.mapNotNullTo(mutableListOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapTo: MutableList<Int> = list.<caret>filter { it > 1 }.mapTo(mutableListOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapTo: MutableList<Int> = list.asSequence().filter { it > 1 }.mapTo(mutableListOf()) { it }
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val max: Int? = list.<caret>filter { it > 1 }.max()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val max: Int? = list.asSequence().filter { it > 1 }.max()
}

Some files were not shown because too many files have changed in this diff Show More