FoldInitializerAndIfToElvisInspection: don't add explicit type if var is used as non-nullable

#KT-38349 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-06-01 08:44:57 +09:00
committed by Yan Zhulanow
parent 3e632d074e
commit bb7d4c224f
5 changed files with 26 additions and 12 deletions
@@ -1,4 +1,3 @@
// PROBLEM: none
fun test(foo: Int?, bar: Int): Int {
var i = foo
<caret>if (i == null) {
@@ -0,0 +1,4 @@
fun test(foo: Int?, bar: Int): Int {
var i = foo ?: return bar
return i
}
@@ -1,4 +1,3 @@
// PROBLEM: none
fun test(foo: Int?, bar: Int): Int {
var i = foo
<caret>if (i == null) {
@@ -0,0 +1,8 @@
fun test(foo: Int?, bar: Int): Int {
var i = foo ?: return bar
baz(i)
val j = i + 1
return j
}
fun baz(i: Int?) {}