Files
kotlin-fork/compiler/testData/diagnostics/tests/when/deprecatedSyntaxInConditionsNoSubject.kt
T
Mikhail Glukhikh 53d6ac24e5 Switch kotlin version to 1.7
* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
2022-02-25 11:46:27 +00:00

62 lines
1.9 KiB
Kotlin
Vendored

// LANGUAGE: +ProhibitConfusingSyntaxInWhenBranches
// DIAGNOSTICS: -INCOMPATIBLE_TYPES, -NON_EXHAUSTIVE_WHEN_STATEMENT, -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
// ISSUE: KT-48385
operator fun Boolean.plus(other: Boolean): Boolean = true
operator fun Boolean.minus(other: Boolean): Boolean = true
operator fun Boolean.times(other: Boolean): Boolean = true
operator fun Boolean.div(other: Boolean): Boolean = true
operator fun Boolean.rem(other: Boolean): Boolean = true
operator fun Boolean.rangeTo(other: Boolean): Boolean = true
fun Boolean.id(): Boolean = true
operator fun Boolean.inc(): Boolean = true
operator fun Boolean.dec(): Boolean = true
operator fun Boolean.plusAssign(other: Boolean) {}
operator fun Boolean.minusAssign(other: Boolean) {}
operator fun Boolean.timesAssign(other: Boolean) {}
operator fun Boolean.divAssign(other: Boolean) {}
operator fun Boolean.remAssign(other: Boolean) {}
operator fun Any?.contains(other: Any): Boolean = false
fun testWithSubject_ok(x: Boolean, y: Boolean?, any: Any, z: Boolean) {
when {
x.id() -> {}
<!TYPE_MISMATCH!>y?.id()<!> -> {}
<!TYPE_MISMATCH!>any as? Boolean<!> -> {}
any as Boolean -> {}
x * x -> {}
x / x -> {}
x % x -> {}
x + x -> {}
x - x -> {}
x..x -> {}
<!TYPE_MISMATCH!>y<!> -> {}
y ?: x -> {}
x in x -> {}
x !in x -> {}
x is String -> {}
x !is String -> {}
x <!OVERLOAD_RESOLUTION_AMBIGUITY!><<!> x -> {}
x <!OVERLOAD_RESOLUTION_AMBIGUITY!>><!> x -> {}
x <!OVERLOAD_RESOLUTION_AMBIGUITY!><=<!> x -> {}
x <!OVERLOAD_RESOLUTION_AMBIGUITY!>>=<!> x -> {}
x == x -> {}
x != x -> {}
<!DEPRECATED_IDENTITY_EQUALS!>x === x<!> -> {}
<!DEPRECATED_IDENTITY_EQUALS!>x !== x<!> -> {}
x && x -> {}
x || x -> {}
}
var b = z
<!NO_ELSE_IN_WHEN!>when<!> (z) {
b++ -> {}
b-- -> {}
}
}