Files
kotlin-fork/idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/noElseBlockAsExpression.kt
T
2017-12-26 18:39:47 +03:00

15 lines
318 B
Kotlin
Vendored

// PROBLEM: none
// 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
}
}