"Replace 'if' with elvis operator": don't suggest if val initializer is a complex expression

#KT-35165 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-12-10 23:14:35 +09:00
committed by Yan Zhulanow
parent 653e20dcba
commit 86ac44c23e
3 changed files with 34 additions and 6 deletions
@@ -0,0 +1,12 @@
// PROBLEM: none
private fun foo(arg: Any): Int {
val x =
if (arg is String)
(arg.length + 1)
else
arg.hashCode()
if (<caret>x == null) return 0
return x
}