Merge branch 'for-loop-indices' of https://github.com/ElliotM/kotlin into ElliotM-for-loop-indices

This commit is contained in:
Dmitry Jemerov
2015-07-02 13:14:19 +02:00
36 changed files with 358 additions and 0 deletions
@@ -0,0 +1,7 @@
//IS_APPLICABLE: FALSE
// WITH_RUNTIME
fun b(c: List<String>) {
for ((<caret>indexVariable, d) in c.withIndices()) {
}
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// IS_APPLICABLE: FALSE
fun String.withIndices(): Int = 42
fun foo(s: String) {
for (<caret>a in s) {
}
}
@@ -0,0 +1,7 @@
//IS_APPLICABLE: FALSE
//ERROR: Unresolved reference: b
fun foo() {
for (a <caret>in b) {
}
}
@@ -0,0 +1,7 @@
// IS_APPLICABLE: FALSE
// WITH_RUNTIME
fun foo(bar: Map<String, String>) {
for (a <caret>in bar) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: IntArray) {
for (<caret>a in bar) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: IntArray) {
for ((index, a) in bar.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: Iterable<Int>) {
for (<caret>a in bar) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: Iterable<Int>) {
for ((index, a) in bar.withIndices()) {
}
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun a() {
val b = listOf(1,2,3,4,5)
for (<caret>c : Int in b) {
}
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun a() {
val b = listOf(1,2,3,4,5)
for ((index, c : Int) in b.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: Array<Object>) {
for (<caret>a in bar) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: Array<Object>) {
for ((index, a) in bar.withIndices()) {
}
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun a() {
val b = listOf(1,2,3,4,5)
for (<caret>c in b) {
}
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun a() {
val b = listOf(1,2,3,4,5)
for ((index, c) in b.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: Stream<String>) {
for (<caret>a in bar) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: Stream<String>) {
for ((index, a) in bar.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: String) {
for (<caret>a in bar) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: String) {
for ((index, a) in bar.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//IS_APPLICABLE: FALSE
fun foo(bar: List<String>) {
for (<caret>a in bar) {
}
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: FALSE
//WITH_RUNTIME
fun foo(b: List<Int>) : Int {
for ((i, <caret>c) in b.withIndices()) {
return i
}
return 0
}
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// IS_APPLICABLE: FALSE
import java.util.LinkedList
fun Int.withIndices(): List<Pair<Int, Int>> = LinkedList<Pair<Int, Int>>()
fun foo(s: Int) {
for ((index<caret>, a) in s.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: List<Int>) {
for ((i : <caret>Int, b: Int) in bar.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: List<Int>) {
for (b: Int in bar) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: List<String>) {
for ((i,<caret>a) in bar.withIndices()) {
}
}
@@ -0,0 +1,6 @@
//WITH_RUNTIME
fun foo(bar: List<String>) {
for (a in bar) {
}
}