[FIR2IR] Properly insert implicit casts to extension receiver in case of intersection smartcast type

^KT-62863 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-11-02 12:27:30 +02:00
committed by Space Team
parent 50106c740c
commit 420fbad73d
25 changed files with 548 additions and 91 deletions
@@ -0,0 +1,30 @@
FILE fqName:<root> fileName:/genericReceiverOnExtensionWithSmartcast.kt
FUN name:bar visibility:public modality:FINAL <F> ($receiver:F of <root>.bar) returnType:kotlin.Unit
TYPE_PARAMETER name:F index:0 variance: superTypes:[kotlin.CharSequence] reified:false
$receiver: VALUE_PARAMETER name:<this> type:F of <root>.bar
BLOCK_BODY
FUN name:test_1 visibility:public modality:FINAL <T> (x:kotlin.Any) returnType:kotlin.Unit [inline]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.CharSequence] reified:true
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of <root>.test_1
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun bar <F> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<F>: T of <root>.test_1
$receiver: TYPE_OP type=T of <root>.test_1 origin=IMPLICIT_CAST typeOperand=T of <root>.test_1
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
FUN name:test_2 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: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.CharSequence
GET_VAR 'x: kotlin.Any? declared in <root>.test_2' type=kotlin.Any? origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun bar <F> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<F>: kotlin.CharSequence
$receiver: TYPE_OP type=kotlin.CharSequence origin=IMPLICIT_CAST typeOperand=kotlin.CharSequence
GET_VAR 'x: kotlin.Any? declared in <root>.test_2' type=kotlin.Any? origin=null
@@ -0,0 +1,14 @@
// FIR_IDENTICAL
fun <F : CharSequence> F.bar() {}
inline fun <reified T : CharSequence> test_1(x: Any) {
if (x is T) {
x.bar()
}
}
fun test_2(x: Any?) {
if (x is CharSequence) {
x.bar()
}
}
@@ -0,0 +1,18 @@
fun <F : CharSequence> F.bar() {
}
inline fun <reified T : CharSequence> test_1(x: Any) {
when {
x is T -> { // BLOCK
x /*as T */.bar<T>()
}
}
}
fun test_2(x: Any?) {
when {
x is CharSequence -> { // BLOCK
x /*as CharSequence */.bar<CharSequence>()
}
}
}
@@ -0,0 +1,17 @@
// CHECK:
// Mangled name: #bar@0:0(){0§<kotlin.CharSequence>}
// Public signature: /bar|8964320427600610167[0]
// Public signature debug description: bar@0:0(){0§<kotlin.CharSequence>}
fun <F : CharSequence> F.bar(): Unit
// CHECK:
// Mangled name: #test_1(kotlin.Any){0§<kotlin.CharSequence>}
// Public signature: /test_1|-9076880516293570076[0]
// Public signature debug description: test_1(kotlin.Any){0§<kotlin.CharSequence>}
inline fun <reified T : CharSequence> test_1(x: Any): Unit
// CHECK:
// Mangled name: #test_2(kotlin.Any?){}
// Public signature: /test_2|-2820233899677445404[0]
// Public signature debug description: test_2(kotlin.Any?){}
fun test_2(x: Any?): Unit
@@ -0,0 +1,90 @@
FILE fqName:<root> fileName:/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt
CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Bar<T of <root>.Bar>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
CONSTRUCTOR visibility:public <> () returnType:<root>.Bar<T of <root>.Bar> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]'
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 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:specificExt visibility:public modality:FINAL <> ($receiver:<root>.Bar<kotlin.Int>) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:<root>.Bar<kotlin.Int>
BLOCK_BODY
FUN name:test_1_1 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_1' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_1' type=kotlin.Any origin=null
CALL 'public final fun specificExt (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_1' type=kotlin.Any origin=null
FUN name:test_1_2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_2' type=kotlin.Any origin=null
CALL 'public final fun specificExt (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_2' type=kotlin.Any origin=null
FUN name:parameterizedExt visibility:public modality:FINAL <T> ($receiver:<root>.Bar<T of <root>.parameterizedExt>) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
$receiver: VALUE_PARAMETER name:<this> type:<root>.Bar<T of <root>.parameterizedExt>
BLOCK_BODY
FUN name:test_2_1 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.String
$receiver: TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Int
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
FUN name:test_2_2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.String
$receiver: TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Int
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
@@ -0,0 +1,41 @@
// FIR_IDENTICAL
// IGNORE_BACKEND_K1: ANY
// Reason: K1 can't resolve calls in test_2_1 and test_2_2 functions
// SKIP_KLIB_TEST
// Reason: AbstractKlibIrTextTestCase doen't support IGNORE_BACKEND_K1 directive
// ISSUE: KT-62863
class Bar<T>
fun Bar<Int>.specificExt() {}
fun test_1_1(x: Any) {
x as Bar<String>
x as Bar<Int>
x.specificExt()
}
fun test_1_2(x: Any) {
x as Bar<Int>
x as Bar<String>
x.specificExt()
}
fun <T> Bar<T>.parameterizedExt() {}
fun test_2_1(x: Any) {
x as Bar<String>
x as Bar<Int>
x.parameterizedExt<String>()
x.parameterizedExt<Int>()
}
fun test_2_2(x: Any) {
x as Bar<Int>
x as Bar<String>
x.parameterizedExt<String>()
x.parameterizedExt<Int>()
}
@@ -0,0 +1,40 @@
class Bar<T : Any?> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
fun Bar<Int>.specificExt() {
}
fun test_1_1(x: Any) {
x as Bar<String> /*~> Unit */
x /*as Bar<String> */ as Bar<Int> /*~> Unit */
x /*as Bar<Int> */.specificExt()
}
fun test_1_2(x: Any) {
x as Bar<Int> /*~> Unit */
x /*as Bar<Int> */ as Bar<String> /*~> Unit */
x /*as Bar<Int> */.specificExt()
}
fun <T : Any?> Bar<T>.parameterizedExt() {
}
fun test_2_1(x: Any) {
x as Bar<String> /*~> Unit */
x /*as Bar<String> */ as Bar<Int> /*~> Unit */
x /*as Bar<String> */.parameterizedExt<String>()
x /*as Bar<Int> */.parameterizedExt<Int>()
}
fun test_2_2(x: Any) {
x as Bar<Int> /*~> Unit */
x /*as Bar<Int> */ as Bar<String> /*~> Unit */
x /*as Bar<String> */.parameterizedExt<String>()
x /*as Bar<Int> */.parameterizedExt<Int>()
}
@@ -0,0 +1,47 @@
// CHECK:
// Mangled name: Bar
// Public signature: /Bar|null[0]
class Bar<T : Any?> {
// CHECK:
// Mangled name: Bar#<init>(){}
// Public signature: /Bar.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK:
// Mangled name: #parameterizedExt@Bar<0:0>(){0§<kotlin.Any?>}
// Public signature: /parameterizedExt|238116600414962466[0]
// Public signature debug description: parameterizedExt@Bar<0:0>(){0§<kotlin.Any?>}
fun <T : Any?> Bar<T>.parameterizedExt(): Unit
// CHECK:
// Mangled name: #specificExt@Bar<kotlin.Int>(){}
// Public signature: /specificExt|-1310832403295072487[0]
// Public signature debug description: specificExt@Bar<kotlin.Int>(){}
fun Bar<Int>.specificExt(): Unit
// CHECK:
// Mangled name: #test_1_1(kotlin.Any){}
// Public signature: /test_1_1|7398425926544174899[0]
// Public signature debug description: test_1_1(kotlin.Any){}
fun test_1_1(x: Any): Unit
// CHECK:
// Mangled name: #test_1_2(kotlin.Any){}
// Public signature: /test_1_2|7281604678448694217[0]
// Public signature debug description: test_1_2(kotlin.Any){}
fun test_1_2(x: Any): Unit
// CHECK:
// Mangled name: #test_2_1(kotlin.Any){}
// Public signature: /test_2_1|605030431757647889[0]
// Public signature debug description: test_2_1(kotlin.Any){}
fun test_2_1(x: Any): Unit
// CHECK:
// Mangled name: #test_2_2(kotlin.Any){}
// Public signature: /test_2_2|-2792936422375173693[0]
// Public signature debug description: test_2_2(kotlin.Any){}
fun test_2_2(x: Any): Unit
@@ -72,10 +72,12 @@ FILE fqName:<root> fileName:/smartCastAside2.kt
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$receiver: GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
$receiver: TYPE_OP type=<root>.Foo<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Foo<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$receiver: GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
$receiver: TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
FUN name:test_2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
@@ -98,14 +100,16 @@ FILE fqName:<root> fileName:/smartCastAside2.kt
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$receiver: CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL
<T0>: kotlin.Any
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
$receiver: TYPE_OP type=<root>.Foo<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Foo<kotlin.Any>
CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL
<T0>: kotlin.Any
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$receiver: CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL
<T0>: kotlin.Any
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
$receiver: TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL
<T0>: kotlin.Any
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
FUN name:test_3 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
@@ -148,31 +152,33 @@ FILE fqName:<root> fileName:/smartCastAside2.kt
then: GET_VAR 'val tmp_1: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$receiver: BLOCK type=kotlin.Any origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Any [val]
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
WHEN type=kotlin.Any 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_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null
<K>: kotlin.Any
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
$receiver: TYPE_OP type=<root>.Foo<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Foo<kotlin.Any>
BLOCK type=kotlin.Any origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Any [val]
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
WHEN type=kotlin.Any 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_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null
<K>: kotlin.Any
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$receiver: BLOCK type=kotlin.Any origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Any [val]
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
WHEN type=kotlin.Any 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_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null
<K>: kotlin.Any
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
$receiver: TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
BLOCK type=kotlin.Any origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Any [val]
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
WHEN type=kotlin.Any 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_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null
<K>: kotlin.Any
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
@@ -29,8 +29,8 @@ fun test_1(x: Any) {
x /*as Bar<Any> */ as Foo<Any> /*~> Unit */
x /*as Foo<Any> */.foo()
x /*as Bar<Any> */.bar()
x.extFoo<Any>()
x.extBar<Any>()
x /*as Foo<Any> */.extFoo<Any>()
x /*as Bar<Any> */.extBar<Any>()
}
fun test_2(x: Any) {
@@ -38,8 +38,8 @@ fun test_2(x: Any) {
x /*as Bar<Any> */ as Foo<Any>? /*~> Unit */
CHECK_NOT_NULL<Any>(arg0 = x) /*as Foo<Any> */.foo()
CHECK_NOT_NULL<Any>(arg0 = x) /*as Bar<Any> */.bar()
CHECK_NOT_NULL<Any>(arg0 = x).extFoo<Any>()
CHECK_NOT_NULL<Any>(arg0 = x).extBar<Any>()
CHECK_NOT_NULL<Any>(arg0 = x) /*as Foo<Any> */.extFoo<Any>()
CHECK_NOT_NULL<Any>(arg0 = x) /*as Bar<Any> */.extBar<Any>()
}
fun test_3(x: Any) {
@@ -65,13 +65,13 @@ fun test_3(x: Any) {
EQEQ(arg0 = tmp_2, arg1 = null) -> materialize<Any>()
else -> tmp_2
}
}.extFoo<Any>()
} /*as Foo<Any> */.extFoo<Any>()
{ // BLOCK
val tmp_3: Any = x
when {
EQEQ(arg0 = tmp_3, arg1 = null) -> materialize<Any>()
else -> tmp_3
}
}.extBar<Any>()
} /*as Bar<Any> */.extBar<Any>()
}
@@ -53,9 +53,8 @@ FILE fqName:<root> fileName:/smartCastsWithDestructuring.kt
GET_VAR 'x: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
VAR name:c1 type:kotlin.Int [val]
CALL 'public final fun component1 (): kotlin.Int declared in <root>' type=kotlin.Int origin=COMPONENT_N(index=1)
$receiver: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
GET_VAR 'val tmp_0: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
$receiver: GET_VAR 'val tmp_0: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
VAR name:c2 type:kotlin.String [val]
CALL 'public final fun component2 (): kotlin.String declared in <root>' type=kotlin.String origin=COMPONENT_N(index=2)
$receiver: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
$receiver: TYPE_OP type=<root>.I2 origin=IMPLICIT_CAST typeOperand=<root>.I2
GET_VAR 'val tmp_0: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
@@ -19,6 +19,6 @@ fun test(x: I1) {
x !is I2 -> return Unit
}
val tmp_0: I1 = x /*as Any */
val c1: Int = tmp_0 /*as Any */.component1()
val c2: String = tmp_0 /*as Any */.component2()
val c1: Int = tmp_0.component1()
val c2: String = tmp_0 /*as I2 */.component2()
}