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
44 lines
1.1 KiB
Kotlin
Vendored
44 lines
1.1 KiB
Kotlin
Vendored
// !CHECK_TYPE
|
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
|
// !WITH_NEW_INFERENCE
|
|
|
|
class A {
|
|
fun forEach() = this
|
|
fun forEach(i: Int) = this
|
|
}
|
|
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach(i: Int) = i
|
|
|
|
class B {
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach() = this@B
|
|
|
|
fun test(a: A) {
|
|
a.forEach() checkType { _<A>() } // todo
|
|
|
|
with(a) {
|
|
forEach() checkType { _<A>() } // todo
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test2(a: A) {
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach() = ""
|
|
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
@kotlin.internal.HidesMembers
|
|
fun A.forEach(i: Int) = ""
|
|
|
|
a.forEach() checkType { _<String>() }
|
|
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
|
|
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
|
|
forEach() checkType { _<String>() }
|
|
<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
|
}
|
|
} |