[NI] Remove Nothing result type restriction in most cases

Make Nothing as result type not suitable only for if, when, try and ?: special functions.
This commit is contained in:
Pavel Kirpichenkov
2019-12-23 12:28:39 +03:00
parent ae1630f376
commit a9391c8dfb
21 changed files with 172 additions and 41 deletions
@@ -1,4 +1,3 @@
// !WITH_NEW_INFERENCE
// See KT-10913 Bogus unreachable code warning
fun fn() : String? = null
@@ -1,4 +1,3 @@
// !WITH_NEW_INFERENCE
// See KT-10913 Bogus unreachable code warning
fun fn() : String? = null
@@ -8,6 +7,6 @@ fun foo(): String {
}
fun bar(): String {
val x = fn() ?: return ""
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>y<!> =<!> x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() } <!NI;UNREACHABLE_CODE, NI;USELESS_ELVIS, OI;UNREACHABLE_CODE, OI;USELESS_ELVIS!>?: "unreachable"<!>
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>y<!> =<!> x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() } <!UNREACHABLE_CODE, USELESS_ELVIS!>?: "unreachable"<!>
<!UNREACHABLE_CODE!>return y<!>
}