Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt
T
2015-04-29 16:33:24 +02:00

26 lines
859 B
Kotlin
Vendored

// !CHECK_TYPE
// 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>, collection: MutableCollection<String>, prefix : String){
collection.filterToMy(result, {it.startsWith(prefix)})
}
fun test(result: MutableList<in Any>, collection: MutableCollection<String>, prefix : String){
val c = collection.filterToMy(result, {it.startsWith(prefix)})
checkSubtype<MutableCollection<out String>>(c)
}
//from library
fun String.startsWith(<!UNUSED_PARAMETER!>prefix<!>: String) : Boolean {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>