[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
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
// FILE: 2.kt
|
||||
package b
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
// FILE: 2.kt
|
||||
package b
|
||||
@@ -41,7 +42,7 @@ fun test(a: A) {
|
||||
|
||||
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>("")
|
||||
|
||||
with(a) {
|
||||
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
|
||||
forEach() checkType { _<String>() }
|
||||
|
||||
forEach(1) checkType { _<Int>() }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
class A {
|
||||
fun forEach() = this
|
||||
fun forEach(i: Int) = this
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
class A {
|
||||
fun forEach() = this
|
||||
fun forEach(i: Int) = this
|
||||
@@ -35,7 +37,7 @@ fun test2(a: A) {
|
||||
a.forEach() checkType { _<String>() }
|
||||
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
||||
|
||||
with(a) {
|
||||
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
|
||||
forEach() checkType { _<String>() }
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user