[FIR] Try to infer result type of incomplete when expression
^KT-62069 Fixed
This commit is contained in:
committed by
Space Team
parent
e2f245096c
commit
88f7b085e6
+5
-5
@@ -11,18 +11,18 @@ val mlist = MList()
|
||||
fun work() {}
|
||||
|
||||
val xx1 = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
val xx2: Unit = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
val xx2: Unit = <!INITIALIZER_TYPE_MISMATCH!><!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42<!>
|
||||
val xx3 = idAny(<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42)
|
||||
val xx4 = id(<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42)
|
||||
val xx5 = idUnit(<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42)
|
||||
val xx5 = idUnit(<!ARGUMENT_TYPE_MISMATCH!><!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42<!>)
|
||||
val xx6 = null ?: <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
val xx7 = "" + <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
|
||||
val wxx1 = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
val wxx2: Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
val wxx2: Unit = <!INITIALIZER_TYPE_MISMATCH!><!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }<!>
|
||||
val wxx3 = idAny(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
|
||||
val wxx4 = id(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
|
||||
val wxx5 = idUnit(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
|
||||
val wxx5 = idUnit(<!ARGUMENT_TYPE_MISMATCH!><!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }<!>)
|
||||
val wxx6 = null ?: <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
val wxx7 = "" + <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
|
||||
@@ -57,7 +57,7 @@ fun foo1(x: String?) {
|
||||
"" + <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
w@while (true) {
|
||||
x ?: <!INVALID_IF_AS_EXPRESSION!>if<!> (true) break
|
||||
x ?: <!NO_ELSE_IN_WHEN!>when<!> { true -> break@w }
|
||||
x <!USELESS_ELVIS!>?: <!NO_ELSE_IN_WHEN!>when<!> { true -> break@w }<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// ISSUE: KT-62069
|
||||
|
||||
enum class ExhaustiveEnum { ONE, TWO }
|
||||
|
||||
fun exhaust(ee: ExhaustiveEnum) {
|
||||
var v = 0
|
||||
v = <!NO_ELSE_IN_WHEN!>when<!> (ee) {
|
||||
ExhaustiveEnum.ONE -> 1
|
||||
}
|
||||
v = <!INVALID_IF_AS_EXPRESSION!>if<!> (ee == ExhaustiveEnum.ONE) 2
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// ISSUE: KT-62069
|
||||
|
||||
enum class ExhaustiveEnum { ONE, TWO }
|
||||
|
||||
fun exhaust(ee: ExhaustiveEnum) {
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>v<!> = 0
|
||||
v = <!NO_ELSE_IN_WHEN!>when<!> (ee) {
|
||||
ExhaustiveEnum.ONE -> 1
|
||||
}
|
||||
v = <!TYPE_MISMATCH!><!INVALID_IF_AS_EXPRESSION!>if<!> (ee == ExhaustiveEnum.ONE) 2<!>
|
||||
}
|
||||
Reference in New Issue
Block a user