ForLoopsLowering: Handle Iterable.withIndex() where the type is a
bounded type parameter. TODO: Handle Sequences by extending DefaultIterableHandler.
This commit is contained in:
committed by
max-kammerer
parent
e8252ea874
commit
1a2e09e6a5
+16
@@ -0,0 +1,16 @@
|
||||
fun <T : Iterable<*>> test(iterable: T): String {
|
||||
val s = StringBuilder()
|
||||
|
||||
for ((index, x) in iterable.withIndex()) {
|
||||
s.append("$index:$x;")
|
||||
}
|
||||
|
||||
return s.toString()
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInEmptySequenceWithIndex.kt
Vendored
+2
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO: Handle Sequences by extending DefaultIterableHandler.
|
||||
val xs = listOf<Any>().asSequence()
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO: Handle Sequences by extending DefaultIterableHandler.
|
||||
fun <T : Sequence<*>> test(sequence: T): String {
|
||||
val s = StringBuilder()
|
||||
|
||||
for ((index, x) in sequence.withIndex()) {
|
||||
s.append("$index:$x;")
|
||||
}
|
||||
|
||||
return s.toString()
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
Vendored
+2
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO: Handle Sequences by extending DefaultIterableHandler.
|
||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO: Handle Sequences by extending DefaultIterableHandler.
|
||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO: Handle Sequences by extending DefaultIterableHandler.
|
||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO: Handle Sequences by extending DefaultIterableHandler.
|
||||
// FULL_JDK
|
||||
|
||||
val xsl = arrayListOf("a", "b", "c", "d")
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO: Handle Sequences by extending DefaultIterableHandler.
|
||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||
|
||||
fun useAny(x: Any) {}
|
||||
|
||||
Reference in New Issue
Block a user