Don't suggest "if to ?." without else when used in expression position

This commit is contained in:
Mikhail Glukhikh
2017-05-11 20:35:02 +03:00
parent 326d850760
commit a1e00ed9f1
3 changed files with 24 additions and 2 deletions
@@ -0,0 +1,14 @@
// IS_APPLICABLE: false
// ERROR: 'if' must have both main and 'else' branches if used as an expression
// ERROR: Type mismatch: inferred type is Unit but Int was expected
fun maybeFoo(): String? {
return "foo"
}
fun bar(): Int {
val foo = maybeFoo()
return if (foo != null<caret>) {
foo.length
}
}