Regular checkType() is now called during condition analysis, TYPE_MISMATCH_IN_CONDITION removed #KT-11998 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
e6ab2f1c2d
commit
6b945ba103
@@ -7,10 +7,10 @@ fun foo() =
|
||||
when {
|
||||
cond1() -> 12
|
||||
cond2() -> 2
|
||||
<!TYPE_MISMATCH_IN_CONDITION!>4<!> -> 34
|
||||
<!TYPE_MISMATCH_IN_CONDITION!>Pair(1, 2)<!> -> 3
|
||||
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>4<!> -> 34
|
||||
<!TYPE_MISMATCH!>Pair(1, 2)<!> -> 3
|
||||
<!EXPECTED_CONDITION!>in 1..10<!> -> 34
|
||||
<!TYPE_MISMATCH_IN_CONDITION!>4<!> -> 38
|
||||
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>4<!> -> 38
|
||||
<!EXPECTED_CONDITION!>is Int<!> -> 33
|
||||
else -> 34
|
||||
}
|
||||
|
||||
+3
-3
@@ -22,15 +22,15 @@ fun test() {
|
||||
val platformJ = J.staticJ
|
||||
|
||||
if (platformNN) {}
|
||||
if (<!TYPE_MISMATCH, TYPE_MISMATCH_IN_CONDITION!>platformN<!>) {}
|
||||
if (<!TYPE_MISMATCH, TYPE_MISMATCH!>platformN<!>) {}
|
||||
if (platformJ) {}
|
||||
|
||||
while (platformNN) {}
|
||||
while (<!TYPE_MISMATCH, TYPE_MISMATCH_IN_CONDITION!>platformN<!>) {}
|
||||
while (<!TYPE_MISMATCH, TYPE_MISMATCH!>platformN<!>) {}
|
||||
while (platformJ) {}
|
||||
|
||||
do {} while (platformNN)
|
||||
do {} while (<!TYPE_MISMATCH, TYPE_MISMATCH_IN_CONDITION!>platformN<!>)
|
||||
do {} while (<!TYPE_MISMATCH, TYPE_MISMATCH!>platformN<!>)
|
||||
do {} while (platformJ)
|
||||
|
||||
platformNN && false
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// See also: KT-11998
|
||||
data class My(val x: Boolean?)
|
||||
|
||||
fun doIt() {}
|
||||
|
||||
fun foo(my: My) {
|
||||
if (my.x != null) {
|
||||
// my.x should be smart-cast
|
||||
if (<!DEBUG_INFO_SMARTCAST!>my.x<!>) doIt()
|
||||
when (<!DEBUG_INFO_SMARTCAST!>my.x<!>) {
|
||||
true -> doIt()
|
||||
}
|
||||
when {
|
||||
<!DEBUG_INFO_SMARTCAST!>my.x<!> -> doIt()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(x: Boolean?) {
|
||||
if (x != null) {
|
||||
// x should be smart-cast
|
||||
if (<!DEBUG_INFO_SMARTCAST!>x<!>) doIt()
|
||||
when (<!DEBUG_INFO_SMARTCAST!>x<!>) {
|
||||
true -> doIt()
|
||||
}
|
||||
when {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!> -> doIt()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun doIt(): kotlin.Unit
|
||||
public fun foo(/*0*/ my: My): kotlin.Unit
|
||||
|
||||
public final data class My {
|
||||
public constructor My(/*0*/ x: kotlin.Boolean?)
|
||||
public final val x: kotlin.Boolean?
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.Boolean?
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Boolean? = ...): My
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user