Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitForIfAsLastExpressionInLambda.kt
T
Mikhail Zarechenskiy bcc8802014 [NI] Avoid constraints from expected type for effectively empty system
Expression will be checked against expected type later.

 Theoretically, this is not very good, but it aligns with the old
 inference, plus it helps avoiding multiple type mismatch diagnostics.
2019-04-17 12:55:12 +03:00

42 lines
685 B
Kotlin
Vendored

// !LANGUAGE: +NewInference
class Obj
fun foo(): String? {
run {
if (true) return@run
if (true) Obj()
}
run {
if (true) return@run
if (true) return <!TYPE_MISMATCH!>Obj()<!> // correct error, type check against return type of function "foo"
}
run {
if (true)
return@run
else
if (true) <!UNUSED_EXPRESSION!>42<!>
}
run {
if (true)
42
else
<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
}
run {
if (true) return@run
if (true) {
Obj()
} else
if (true) return null
}
return ""
}