// RUN_PIPELINE_TILL: FRONTEND
// LANGUAGE: +WhenGuards
// DIAGNOSTICS: -DUPLICATE_LABEL_IN_WHEN, -USELESS_IS_CHECK

fun EEInConditionWithNoSubject(x: Any) {
    return when {
        if (x is Boolean) true else false -> Unit
        if (x is Boolean) true else if (x is String) true else false -> Unit
        if (x is Boolean) x == false || if (x is String) true else false else if (x is String) true else false -> Unit
        else -> Unit
    }
}

fun IEEInConditionWithGuard(x: Any) {
    return when (x) {
        if (x is Boolean) true else false if true -> Unit
        if (x is Boolean) true else if (x is String) true else false if true -> Unit
        if (x is Boolean) x == false || if (x is String) true else false else if (x is String) true else false if true -> Unit
        else -> Unit
    }
}

fun WronglyPlacedConditionTypeMismatch(x: Any, y: Any?): Int {
    return when (x) {
        true if <!CONDITION_TYPE_MISMATCH!>x<!> -> 10
        else -> 0
    }
}

fun IEEInGuard(x: Any) {
    return when (x) {
        is Boolean if if (x is Boolean) true else false -> Unit
        is Boolean if if (x is Boolean) true else if (x is String) true else false -> Unit
        is Boolean if if (x is Boolean) x == false || if (x is String) true else false else if (x is String) true else false -> Unit
        else -> Unit
    }
}

/* GENERATED_FIR_TAGS: andExpression, disjunctionExpression, equalityExpression, functionDeclaration, guardCondition,
ifExpression, integerLiteral, isExpression, nullableType, smartcast, whenExpression, whenWithSubject */
