Files
kotlin-fork/compiler/testData/diagnostics/tests/generics/kt34729.fir.kt
T
Jinseong Jeon 27c942a0ff FIR: enforce the return type of function literals without body
Its return type should be Unit, so do not use the expected type from,
e.g., parameter type.
2021-02-19 10:17:16 +03:00

20 lines
379 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !LANGUAGE: +NewInference
interface ILength {
val length: Int
}
class Impl(override val length: Int) : ILength
fun <T> foo(a: (Int) -> T) = 0
fun <T : ILength> bar(a: (Int) -> T) {
a(42).length
}
fun test() {
<!INAPPLICABLE_CANDIDATE!>foo<!><String> { }
<!INAPPLICABLE_CANDIDATE!>bar<!><Impl> { }
}