KT-4820: Added new tests, introduced functionality to detect overridden functions, other minor fixes

This commit is contained in:
Ross Hanson
2014-05-09 05:36:46 -04:00
parent 35c5a62b11
commit bbbdfd25d9
30 changed files with 170 additions and 75 deletions
@@ -1,5 +1,5 @@
//IS_APPLICABLE: FALSE
//ERROR: Unresolved reference: withIndices
// 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) {
}
}
@@ -1,5 +1,5 @@
// IS_APPLICABLE: FALSE
// ERROR: For-loop range must have an iterator() method
// 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()) {
}
}
@@ -1,4 +1,4 @@
// ERROR: Unresolved reference: listOf
// WITH_RUNTIME
fun a() {
val b = listOf(1,2,3,4,5)
for (<caret>c : Int in b) {
@@ -1,4 +1,4 @@
// ERROR: Unresolved reference: listOf
// 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()) {
}
}
@@ -1,4 +1,4 @@
// ERROR: Unresolved reference: listOf
// WITH_RUNTIME
fun a() {
val b = listOf(1,2,3,4,5)
for (<caret>c in b) {
@@ -1,4 +1,4 @@
// ERROR: Unresolved reference: listOf
// WITH_RUNTIME
fun a() {
val b = listOf(1,2,3,4,5)
for ((index, c) in b.withIndices()) {
@@ -1,6 +0,0 @@
//ERROR: Unresolved reference: SortedMap
fun a(b: SortedMap<Int, String>) {
for (<caret>c in b) {
}
}
@@ -1,6 +0,0 @@
//ERROR: Unresolved reference: SortedMap
fun a(b: SortedMap<Int, String>) {
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()) {
}
}
@@ -1,7 +1,9 @@
// IS_APPLICABLE: FALSE
//ERROR: Unresolved reference: withIndices
fun foo(b: List<Int>) {
//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()) {
}
}
@@ -1,4 +1,4 @@
//ERROR: Unresolved reference: withIndices
//WITH_RUNTIME
fun foo(bar: List<Int>) {
for ((i : <caret>Int, b: Int) in bar.withIndices()) {
@@ -1,4 +1,4 @@
//ERROR: Unresolved reference: withIndices
//WITH_RUNTIME
fun foo(bar: List<Int>) {
for (b: Int in bar) {
@@ -1,4 +1,4 @@
//ERROR: Unresolved reference: withIndices
//WITH_RUNTIME
fun foo(bar: List<String>) {
for ((i,<caret>a) in bar.withIndices()) {
@@ -1,4 +1,4 @@
//ERROR: Unresolved reference: withIndices
//WITH_RUNTIME
fun foo(bar: List<String>) {
for (a in bar) {