c5893913f3
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
54 lines
1.1 KiB
Kotlin
Vendored
54 lines
1.1 KiB
Kotlin
Vendored
// !CHECK_TYPE
|
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
|
// !WITH_NEW_INFERENCE
|
|
|
|
// FILE: 2.kt
|
|
package b
|
|
|
|
import a.A
|
|
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach(i: Int) = i
|
|
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach(s: String) {}
|
|
|
|
|
|
// FILE: 1.kt
|
|
package a
|
|
|
|
import b.*
|
|
|
|
class A {
|
|
fun forEach() = this
|
|
fun forEach(i: Int) = this
|
|
fun forEach(i: String) = this
|
|
}
|
|
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach() = ""
|
|
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach(s: String) {}
|
|
|
|
fun test(a: A) {
|
|
a.forEach() checkType { _<String>() }
|
|
|
|
a.forEach(1) checkType { _<Int>() }
|
|
|
|
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>("")
|
|
|
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
|
|
forEach() checkType { _<String>() }
|
|
|
|
forEach(1) checkType { _<Int>() }
|
|
|
|
<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>("")
|
|
}
|
|
}
|
|
|