[FE 1.0] Don't lose diagnostics during lambda analysis at the overload resolution by return type stage

^KT-49658 Fixed
This commit is contained in:
Victor Petukhov
2022-01-11 15:22:03 +03:00
committed by teamcity
parent 7820b268fb
commit 37d163d417
17 changed files with 212 additions and 21 deletions
@@ -0,0 +1,17 @@
// !LANGUAGE: +DontLoseDiagnosticsDuringOverloadResolutionByReturnType
// WITH_STDLIB
fun doTheMapThing1(elements: List<CharSequence>): List<String> {
return elements.flatMap {
<!ARGUMENT_TYPE_MISMATCH!>when (it) { // NullPointerException
is String -> listOf("Yeah")
else -> null
}<!>
}
}
fun doTheMapThing2(elements: List<CharSequence>): List<String> {
return elements.flatMap {
<!ARGUMENT_TYPE_MISMATCH!>if (it is String) listOf("Yeah") else null<!> // it's OK with `if`
}
}