[IR] Extend test coverage for smart cast handling.
This commit is contained in:
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
FILE fqName:<root> fileName:/nullableAnyAsIntToDouble.kt
|
||||
FUN name:test visibility:public modality:FINAL <> (x:kotlin.Any?, y:kotlin.Double) returnType:kotlin.Boolean
|
||||
VALUE_PARAMETER name:x index:0 type:kotlin.Any?
|
||||
VALUE_PARAMETER name:y index:1 type:kotlin.Double
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test (x: kotlin.Any?, y: kotlin.Double): kotlin.Boolean declared in <root>'
|
||||
WHEN type=kotlin.Boolean origin=ANDAND
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Int
|
||||
GET_VAR 'x: kotlin.Any? declared in <root>.test' type=kotlin.Any? origin=null
|
||||
then: CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'public open fun toDouble (): kotlin.Double declared in kotlin.Int' type=kotlin.Double origin=null
|
||||
$this: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int
|
||||
GET_VAR 'x: kotlin.Any? declared in <root>.test' type=kotlin.Any? origin=null
|
||||
arg1: GET_VAR 'y: kotlin.Double declared in <root>.test' type=kotlin.Double origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
Vendored
+1
@@ -1,2 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
fun test(x: Any?, y: Double) =
|
||||
x is Int && x < y
|
||||
@@ -0,0 +1,22 @@
|
||||
interface IC1 {
|
||||
abstract operator fun component1(): Int
|
||||
|
||||
}
|
||||
|
||||
interface IC2 {
|
||||
abstract operator fun component2(): String
|
||||
|
||||
}
|
||||
|
||||
fun test(x: Any) {
|
||||
when {
|
||||
when {
|
||||
x is IC1 -> x /*as IC1 */ is IC2
|
||||
else -> false
|
||||
} -> { // BLOCK
|
||||
val <destruct>: IC1 = x /*as IC1 */
|
||||
val x1: Int = <destruct>.component1()
|
||||
val x2: String = <destruct> /*as IC2 */.component2()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
FILE fqName:<root> fileName:/multipleSmartCasts.kt
|
||||
CLASS INTERFACE name:IC1 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IC1
|
||||
FUN name:component1 visibility:public modality:ABSTRACT <> ($this:<root>.IC1) returnType:kotlin.Int [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IC1
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:IC2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IC2
|
||||
FUN name:component2 visibility:public modality:ABSTRACT <> ($this:<root>.IC2) returnType:kotlin.String [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IC2
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:test visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:x index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: WHEN type=kotlin.Boolean origin=ANDAND
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.IC1
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.IC2
|
||||
TYPE_OP type=<root>.IC1 origin=IMPLICIT_CAST typeOperand=<root>.IC1
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.IC1 [val]
|
||||
TYPE_OP type=<root>.IC1 origin=IMPLICIT_CAST typeOperand=<root>.IC1
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
VAR name:x1 type:kotlin.Int [val]
|
||||
CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in <root>.IC1' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'val tmp_0: <root>.IC1 [val] declared in <root>.test' type=<root>.IC1 origin=null
|
||||
VAR name:x2 type:kotlin.String [val]
|
||||
CALL 'public abstract fun component2 (): kotlin.String [operator] declared in <root>.IC2' type=kotlin.String origin=null
|
||||
$this: TYPE_OP type=<root>.IC2 origin=IMPLICIT_CAST typeOperand=<root>.IC2
|
||||
GET_VAR 'val tmp_0: <root>.IC1 [val] declared in <root>.test' type=<root>.IC1 origin=null
|
||||
@@ -0,0 +1,13 @@
|
||||
interface IC1 {
|
||||
operator fun component1(): Int
|
||||
}
|
||||
|
||||
interface IC2 {
|
||||
operator fun component2(): String
|
||||
}
|
||||
|
||||
fun test(x: Any) {
|
||||
if (x is IC1 && x is IC2) {
|
||||
val (x1, x2) = x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
interface IC1 {
|
||||
abstract operator fun component1(): Int
|
||||
|
||||
}
|
||||
|
||||
interface IC2 {
|
||||
abstract operator fun component2(): String
|
||||
|
||||
}
|
||||
|
||||
fun test(x: Any) {
|
||||
when {
|
||||
when {
|
||||
x is IC1 -> x is IC2
|
||||
else -> false
|
||||
} -> { // BLOCK
|
||||
// COMPOSITE {
|
||||
val tmp0_container: Any = x
|
||||
val x1: Int = tmp0_container /*as IC1 */.component1()
|
||||
val x2: String = tmp0_container /*as IC2 */.component2()
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
FILE fqName:<root> fileName:/multipleSmartCasts.kt
|
||||
CLASS INTERFACE name:IC1 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IC1
|
||||
FUN name:component1 visibility:public modality:ABSTRACT <> ($this:<root>.IC1) returnType:kotlin.Int [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IC1
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:IC2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IC2
|
||||
FUN name:component2 visibility:public modality:ABSTRACT <> ($this:<root>.IC2) returnType:kotlin.String [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IC2
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:test visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:x index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: WHEN type=kotlin.Boolean origin=ANDAND
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.IC1
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.IC2
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any [val]
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
VAR name:x1 type:kotlin.Int [val]
|
||||
CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in <root>.IC1' type=kotlin.Int origin=COMPONENT_N(index=1)
|
||||
$this: TYPE_OP type=<root>.IC1 origin=IMPLICIT_CAST typeOperand=<root>.IC1
|
||||
GET_VAR 'val tmp_0: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
VAR name:x2 type:kotlin.String [val]
|
||||
CALL 'public abstract fun component2 (): kotlin.String [operator] declared in <root>.IC2' type=kotlin.String origin=COMPONENT_N(index=2)
|
||||
$this: TYPE_OP type=<root>.IC2 origin=IMPLICIT_CAST typeOperand=<root>.IC2
|
||||
GET_VAR 'val tmp_0: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
@@ -0,0 +1,54 @@
|
||||
enum class En : Enum<En> {
|
||||
private constructor() /* primary */ {
|
||||
super/*Enum*/<En>()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
A = En()
|
||||
|
||||
B = En()
|
||||
|
||||
C = En()
|
||||
|
||||
fun values(): Array<En> /* Synthetic body for ENUM_VALUES */
|
||||
|
||||
fun valueOf(value: String): En /* Synthetic body for ENUM_VALUEOF */
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
var r: String = ""
|
||||
val x: Any? = En.A
|
||||
when {
|
||||
x /*as En */ is En -> { // BLOCK
|
||||
val tmp0_subject: En = x /*as En */
|
||||
when {
|
||||
EQEQ(arg0 = tmp0_subject, arg1 = En.A) -> { // BLOCK
|
||||
r = "when1"
|
||||
}
|
||||
EQEQ(arg0 = tmp0_subject, arg1 = En.B) -> { // BLOCK
|
||||
}
|
||||
EQEQ(arg0 = tmp0_subject, arg1 = En.C) -> { // BLOCK
|
||||
}
|
||||
else -> noWhenBranchMatchedException()
|
||||
}
|
||||
}
|
||||
}
|
||||
val y: Any = En.A
|
||||
when {
|
||||
y /*as En */ is En -> { // BLOCK
|
||||
val tmp1_subject: En = y /*as En */
|
||||
when {
|
||||
EQEQ(arg0 = tmp1_subject, arg1 = En.A) -> { // BLOCK
|
||||
r = "when2"
|
||||
}
|
||||
EQEQ(arg0 = tmp1_subject, arg1 = En.B) -> { // BLOCK
|
||||
}
|
||||
EQEQ(arg0 = tmp1_subject, arg1 = En.C) -> { // BLOCK
|
||||
}
|
||||
else -> noWhenBranchMatchedException()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
FILE fqName:<root> fileName:/whenSmartCastToEnum.kt
|
||||
CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.En>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.En [primary]
|
||||
BLOCK_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
|
||||
<E>: <root>.En
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.En>]'
|
||||
ENUM_ENTRY name:A
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
|
||||
ENUM_ENTRY name:B
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
|
||||
ENUM_ENTRY name:C
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.En>
|
||||
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.En
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String
|
||||
SYNTHETIC_BODY kind=ENUM_VALUEOF
|
||||
FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.Any [fake_override]
|
||||
overridden:
|
||||
protected final fun clone (): kotlin.Any declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>, other:<root>.En) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.En
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun hashCode (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
|
||||
PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
|
||||
PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
|
||||
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR name:r type:kotlin.String [var]
|
||||
CONST String type=kotlin.String value=""
|
||||
VAR name:x type:kotlin.Any? [val]
|
||||
GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.En
|
||||
TYPE_OP type=<root>.En origin=IMPLICIT_CAST typeOperand=<root>.En
|
||||
GET_VAR 'val x: kotlin.Any? [val] declared in <root>.test' type=kotlin.Any? origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=WHEN
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.En [val]
|
||||
TYPE_OP type=<root>.En origin=IMPLICIT_CAST typeOperand=<root>.En
|
||||
GET_VAR 'val x: kotlin.Any? [val] declared in <root>.test' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Unit origin=WHEN
|
||||
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_0: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var r: kotlin.String [var] declared in <root>.test' type=kotlin.Unit origin=EQ
|
||||
CONST String type=kotlin.String value="when1"
|
||||
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_0: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:B' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
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_0: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:C' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null
|
||||
VAR name:y type:kotlin.Any [val]
|
||||
GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.En
|
||||
TYPE_OP type=<root>.En origin=IMPLICIT_CAST typeOperand=<root>.En
|
||||
GET_VAR 'val y: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=WHEN
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:<root>.En [val]
|
||||
TYPE_OP type=<root>.En origin=IMPLICIT_CAST typeOperand=<root>.En
|
||||
GET_VAR 'val y: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
WHEN type=kotlin.Unit origin=WHEN
|
||||
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_1: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var r: kotlin.String [var] declared in <root>.test' type=kotlin.Unit origin=EQ
|
||||
CONST String type=kotlin.String value="when2"
|
||||
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_1: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:B' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
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_1: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:C' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null
|
||||
@@ -0,0 +1,23 @@
|
||||
enum class En { A, B, C }
|
||||
|
||||
fun test() {
|
||||
var r = ""
|
||||
|
||||
val x: Any? = En.A
|
||||
if (x is En) {
|
||||
when (x) {
|
||||
En.A -> { r = "when1" }
|
||||
En.B -> {}
|
||||
En.C -> {}
|
||||
}
|
||||
}
|
||||
|
||||
val y: Any = En.A
|
||||
if (y is En) {
|
||||
when (y) {
|
||||
En.A -> { r = "when2" }
|
||||
En.B -> {}
|
||||
En.C -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
enum class En : Enum<En> {
|
||||
private constructor() /* primary */ {
|
||||
super/*Enum*/<En>()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
A = En()
|
||||
|
||||
B = En()
|
||||
|
||||
C = En()
|
||||
|
||||
fun values(): Array<En> /* Synthetic body for ENUM_VALUES */
|
||||
|
||||
fun valueOf(value: String): En /* Synthetic body for ENUM_VALUEOF */
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
var r: String = ""
|
||||
val x: Any? = En.A
|
||||
when {
|
||||
x is En -> { // BLOCK
|
||||
{ // BLOCK
|
||||
val tmp0_subject: En = x /*as En */
|
||||
when {
|
||||
EQEQ(arg0 = tmp0_subject, arg1 = En.A) -> { // BLOCK
|
||||
r = "when1"
|
||||
}
|
||||
EQEQ(arg0 = tmp0_subject, arg1 = En.B) -> { // BLOCK
|
||||
}
|
||||
EQEQ(arg0 = tmp0_subject, arg1 = En.C) -> { // BLOCK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val y: Any = En.A
|
||||
when {
|
||||
y is En -> { // BLOCK
|
||||
{ // BLOCK
|
||||
val tmp1_subject: En = y /*as En */
|
||||
when {
|
||||
EQEQ(arg0 = tmp1_subject, arg1 = En.A) -> { // BLOCK
|
||||
r = "when2"
|
||||
}
|
||||
EQEQ(arg0 = tmp1_subject, arg1 = En.B) -> { // BLOCK
|
||||
}
|
||||
EQEQ(arg0 = tmp1_subject, arg1 = En.C) -> { // BLOCK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
FILE fqName:<root> fileName:/whenSmartCastToEnum.kt
|
||||
CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.En>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.En [primary]
|
||||
BLOCK_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
|
||||
<E>: <root>.En
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.En>]'
|
||||
ENUM_ENTRY name:A
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
|
||||
ENUM_ENTRY name:B
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
|
||||
ENUM_ENTRY name:C
|
||||
init: EXPRESSION_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
|
||||
FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<<root>.En>) returnType:kotlin.Any [fake_override]
|
||||
overridden:
|
||||
protected final fun clone (): kotlin.Any declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<<root>.En>) returnType:kotlin.Unit [fake_override]
|
||||
overridden:
|
||||
protected/*protected and package*/ final fun finalize (): kotlin.Unit declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.En>) returnType:@[FlexibleNullability] java.lang.Class<@[FlexibleNullability] <root>.En?>? [fake_override]
|
||||
overridden:
|
||||
public final fun getDeclaringClass (): @[FlexibleNullability] java.lang.Class<@[FlexibleNullability] E of kotlin.Enum?>? declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.En>, other:<root>.En) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.En
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.En>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.En>) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun hashCode (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.En>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.En>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.En>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.En>
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.En>
|
||||
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.En
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String
|
||||
SYNTHETIC_BODY kind=ENUM_VALUEOF
|
||||
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR name:r type:kotlin.String [var]
|
||||
CONST String type=kotlin.String value=""
|
||||
VAR name:x type:kotlin.Any? [val]
|
||||
GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.En
|
||||
GET_VAR 'val x: kotlin.Any? [val] declared in <root>.test' type=kotlin.Any? origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BLOCK type=kotlin.Unit origin=WHEN
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.En [val]
|
||||
TYPE_OP type=<root>.En origin=IMPLICIT_CAST typeOperand=<root>.En
|
||||
GET_VAR 'val x: kotlin.Any? [val] declared in <root>.test' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Unit origin=WHEN
|
||||
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_0: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var r: kotlin.String [var] declared in <root>.test' type=kotlin.Unit origin=EQ
|
||||
CONST String type=kotlin.String value="when1"
|
||||
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_0: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:B' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
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_0: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:C' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:y type:kotlin.Any [val]
|
||||
GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.En
|
||||
GET_VAR 'val y: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BLOCK type=kotlin.Unit origin=WHEN
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:<root>.En [val]
|
||||
TYPE_OP type=<root>.En origin=IMPLICIT_CAST typeOperand=<root>.En
|
||||
GET_VAR 'val y: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
WHEN type=kotlin.Unit origin=WHEN
|
||||
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_1: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:A' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var r: kotlin.String [var] declared in <root>.test' type=kotlin.Unit origin=EQ
|
||||
CONST String type=kotlin.String value="when2"
|
||||
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_1: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:B' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
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_1: <root>.En [val] declared in <root>.test' type=<root>.En origin=null
|
||||
arg1: GET_ENUM 'ENUM_ENTRY name:C' type=<root>.En
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
Reference in New Issue
Block a user