[FIR] Properly support smartcasts on stable when subjects in when conditions
^KT-49860 Fixed
This commit is contained in:
committed by
teamcityserver
parent
20425fb458
commit
330574cab6
Vendored
+3
-2
@@ -75,8 +75,9 @@ FILE fqName:<root> fileName:/whenByFloatingPoint.kt
|
||||
GET_VAR 'val tmp_3: kotlin.Any [val] declared in <root>.testSmartCastInWhenConditionInBranch' type=kotlin.Any origin=null
|
||||
then: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_3: kotlin.Any [val] declared in <root>.testSmartCastInWhenConditionInBranch' type=kotlin.Any origin=null
|
||||
if: CALL 'public final fun ieee754equals (arg0: kotlin.Double?, arg1: kotlin.Double?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double
|
||||
GET_VAR 'val tmp_3: kotlin.Any [val] declared in <root>.testSmartCastInWhenConditionInBranch' type=kotlin.Any origin=null
|
||||
arg1: CONST Double type=kotlin.Double value=0.0
|
||||
then: CONST Int type=kotlin.Int value=0
|
||||
BRANCH
|
||||
|
||||
Vendored
+2
-1
@@ -39,7 +39,7 @@ fun testSmartCastInWhenConditionInBranch(x: Any): Int {
|
||||
val tmp3_subject: Any = x
|
||||
when {
|
||||
tmp3_subject !is Double -> -1
|
||||
EQEQ(arg0 = tmp3_subject, arg1 = 0.0) -> 0
|
||||
ieee754equals(arg0 = tmp3_subject /*as Double */, arg1 = 0.0) -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
@@ -77,3 +77,4 @@ fun testWithPrematureExitInConditionSubexpression(x: Any): Int {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -46,10 +46,11 @@ FILE fqName:<root> fileName:/when.kt
|
||||
then: CONST String type=kotlin.String value="!Number"
|
||||
BRANCH
|
||||
if: CALL 'public final fun contains <T> (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=IN
|
||||
<T>: kotlin.Any?
|
||||
<T>: kotlin.Number
|
||||
$receiver: CALL 'public final fun setOf <T> (): kotlin.collections.Set<T of kotlin.collections.SetsKt.setOf> [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.Set<kotlin.Nothing> origin=null
|
||||
<T>: kotlin.Nothing
|
||||
element: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in <root>.testWithSubject' type=kotlin.Any? origin=null
|
||||
element: TYPE_OP type=kotlin.Number origin=IMPLICIT_CAST typeOperand=kotlin.Number
|
||||
GET_VAR 'val tmp_0: kotlin.Any? [val] declared in <root>.testWithSubject' type=kotlin.Any? origin=null
|
||||
then: CONST String type=kotlin.String value="nothingness?"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
|
||||
+2
-1
@@ -15,7 +15,7 @@ fun testWithSubject(x: Any?): String {
|
||||
EQEQ(arg0 = tmp0_subject, arg1 = A) -> "A"
|
||||
tmp0_subject is String -> "String"
|
||||
tmp0_subject !is Number -> "!Number"
|
||||
setOf<Nothing>().contains<Any?>(element = tmp0_subject) -> "nothingness?"
|
||||
setOf<Nothing>().contains<Number>(element = tmp0_subject /*as Number */) -> "nothingness?"
|
||||
else -> "something"
|
||||
}
|
||||
}
|
||||
@@ -61,3 +61,4 @@ fun testComma(x: Int): String {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user