Files
kotlin-fork/compiler/testData/diagnostics/tests/resolve/invoke/wrongInvokeExtension.kt
T
Pavel Kirpichenkov c5893913f3 [NI] Remove lambda coersion to Unit in case of error return type(s)
Coersion to Unit from error type leads to misleading type mismatches:
"expected <expected lambda return type> found Unit", despite no user-provided Unit / empty lambda.
These diagnostics were collected, but not reported before, and that had been disguising the issue for a while.

KT-34729 Fixed
2020-01-23 13:18:50 +03:00

21 lines
377 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
class B
class A {
operator fun B.invoke() {}
}
val B.a: () -> Int get() = { 5 }
fun test(a: A, b: B) {
val <!UNUSED_VARIABLE!>x<!>: Int = b.a()
b.<!FUNCTION_EXPECTED!>(a)<!>()
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(b) {
val <!UNUSED_VARIABLE!>y<!>: Int = a()
<!FUNCTION_EXPECTED!>(a)<!>()
}
}