Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt
T
2012-11-24 15:59:16 +04:00

24 lines
837 B
Kotlin

// KT-1410 Compiler does automatically infer type argument when using variance
//+JDK
package d
public fun <T> MutableCollection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : MutableCollection<out T> {
for (t in this){
if (filter(t)){
result.add(t)
}
}
return this
}
fun foo(result: MutableList<in String>, val collection: MutableCollection<String>, prefix : String){
collection.filterToMy(result, {it.startsWith(prefix)})
}
fun test(result: MutableList<in Any>, val collection: MutableCollection<String>, prefix : String){
val c = collection.filterToMy(result, {it.startsWith(prefix)})
c: MutableCollection<out String>
}
//from library
fun String.startsWith(<!UNUSED_PARAMETER!>prefix<!>: String) : Boolean {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>