Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/mapFunction.kt
T
2012-09-05 18:55:16 +04:00

32 lines
650 B
Kotlin

package a
//+JDK
import java.util.*
fun foo() {
val v = array(1, 2, 3)
val u = v map { it * 2 }
u : List<Int>
val a = 1..5
val b = a.map { it * 2 }
b : List<Int>
//check for non-error types
<!TYPE_MISMATCH!>u<!> : String
<!TYPE_MISMATCH!>b<!> : String
}
// ---------------------
// copy from kotlin util
fun <T> array(vararg t : T) : Array<T> = t
fun <T, R> Array<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>