07ff53d456
otherwise I have to rollback dozens of files after using sed that follows conventions
33 lines
781 B
Plaintext
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
|
|
}
|