Files
kotlin-fork/compiler/testData/diagnostics/tests/regressions/kt353.jet
T
Stepan Koltsov 07ff53d456 add trailing newlines to test files
otherwise I have to rollback dozens of files after using sed that follows conventions
2012-03-12 22:54:14 +04:00

33 lines
781 B
Plaintext

// 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_FAILED!>gen()<!> // Shouldn't work: no info for inference
}
val <!UNUSED_VARIABLE!>b<!> : () -> Unit = {
if (true) {
a.gen() // unit can be inferred
}
else {
#()
}
}
val <!UNUSED_VARIABLE!>f<!> : () -> Int = { () : Int ->
a.gen() //type mismatch, but Int can be derived
}
a.<!TYPE_INFERENCE_FAILED!>gen()<!> // Shouldn't work: no info for inference
}