Do not unbox nullable Result, since before usage it is coerced

#KT-46505
This commit is contained in:
Ilmir Usmanov
2021-05-10 13:07:23 +02:00
parent 656c2496a6
commit 640d263ae1
19 changed files with 254 additions and 27 deletions
@@ -6,17 +6,22 @@ object Foo {
}
fun bar(value: Value?) {
res = value?.value!!
res = value?.value
}
}
var res = "FAIL"
var res: String? = "FAIL"
fun box(): String {
Value("OK").let(Foo::foo)
if (res != "OK") return "FAIL 1: $res"
res = "FAIL"
res = "FAIL 2"
Value("OK").let(Foo::bar)
return res
if (res != "OK") return "FAIL 3: $res"
res = "FAIL 4"
null.let(Foo::bar)
if (res != null) return "FAIL 3: $res"
return "OK"
}