Files
kotlin-fork/compiler/testData/diagnostics/tests/regressions/kt353.kt
T
Andrey Breslav 5eaa5b396b Removing usages of tuples from test data
(KT-2358 Drop tuples)
 #KT-2358 In progress
2012-09-18 20:27:09 +04:00

32 lines
831 B
Kotlin

// KT-353 Generic type argument inference sometimes doesn't work
trait A {
fun <T> gen() : T
}
fun foo(a: A) {
val <!UNUSED_VARIABLE!>g<!> : () -> Unit = {
a.gen() //it works: Unit is derived
}
val <!UNUSED_VARIABLE!>u<!>: Unit = a.gen() // Unit should be inferred
if (true) {
a.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>gen<!>() // Shouldn't work: no info for inference
}
val <!UNUSED_VARIABLE!>b<!> : () -> Unit = {
if (true) {
a.gen() // unit can be inferred
}
else {
Unit.VALUE
}
}
val <!UNUSED_VARIABLE!>f<!> : () -> Int = { () : Int ->
a.gen() //type mismatch, but Int can be derived
}
a.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>gen<!>() // Shouldn't work: no info for inference
}