K2: reproduce situation from KT-62863

This commit is contained in:
Mikhail Glukhikh
2023-10-30 15:53:52 +01:00
committed by Space Team
parent 168b3416ea
commit 50106c740c
16 changed files with 687 additions and 0 deletions
@@ -2014,6 +2014,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -2014,6 +2014,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -0,0 +1,178 @@
FILE fqName:<root> fileName:/smartCastAside2.kt
FUN name:materialize visibility:public modality:FINAL <K> () returnType:K of <root>.materialize
TYPE_PARAMETER name:K index:0 variance: superTypes:[kotlin.Any?] reified:false
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun materialize <K> (): K of <root>.materialize declared in <root>'
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.Nothing origin=EXCLEXCL
<T0>: kotlin.Nothing
arg0: CONST Null type=kotlin.Nothing? value=null
CLASS INTERFACE name:Foo modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Foo<T of <root>.Foo>
TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any?] reified:false
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.Foo<T of <root>.Foo>) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Foo<T of <root>.Foo>
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
CLASS CLASS name:Bar modality:ABSTRACT 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:ABSTRACT visibility:public superTypes:[kotlin.Any]'
FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.Bar<T of <root>.Bar>) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Bar<T of <root>.Bar>
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:extFoo visibility:public modality:FINAL <T> ($receiver:<root>.Foo<T of <root>.extFoo>) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
$receiver: VALUE_PARAMETER name:<this> type:<root>.Foo<T of <root>.extFoo>
BLOCK_BODY
FUN name:extBar visibility:public modality:FINAL <T> ($receiver:<root>.Bar<T of <root>.extBar>) 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>.extBar>
BLOCK_BODY
FUN name:test_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.Any> origin=CAST typeOperand=<root>.Bar<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Foo<kotlin.Any> origin=CAST typeOperand=<root>.Foo<kotlin.Any>
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
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: 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 abstract fun bar (): kotlin.Unit declared in <root>.Bar' type=kotlin.Unit origin=null
$this: 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
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
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
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
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Any>? origin=CAST typeOperand=<root>.Bar<kotlin.Any>?
GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Foo<kotlin.Any>? origin=CAST typeOperand=<root>.Foo<kotlin.Any>?
TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: 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 abstract fun bar (): kotlin.Unit declared in <root>.Bar' type=kotlin.Unit origin=null
$this: 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
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
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
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
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Any>? origin=CAST typeOperand=<root>.Bar<kotlin.Any>?
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Foo<kotlin.Any>? origin=CAST typeOperand=<root>.Foo<kotlin.Any>?
TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: 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_0 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_0: 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_0: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public abstract fun bar (): kotlin.Unit declared in <root>.Bar' type=kotlin.Unit origin=null
$this: 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_1 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_1: 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_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
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
@@ -0,0 +1,77 @@
fun <K : Any?> materialize(): K {
return CHECK_NOT_NULL<Nothing>(arg0 = null)
}
interface Foo<out T : Any?> {
abstract fun foo()
}
abstract class Bar<T : Any> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
abstract fun bar()
}
fun <T : Any?> Foo<T>.extFoo() {
}
fun <T : Any> Bar<T>.extBar() {
}
fun test_1(x: Any) {
x as Bar<Any> /*~> Unit */
x /*as Bar<Any> */ as Foo<Any> /*~> Unit */
x /*as Foo<Any> */.foo()
x /*as Bar<Any> */.bar()
x.extFoo<Any>()
x.extBar<Any>()
}
fun test_2(x: Any) {
x as Bar<Any>? /*~> Unit */
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>()
}
fun test_3(x: Any) {
x as Bar<Any>? /*~> Unit */
x /*as Bar<Any> */ as Foo<Any>? /*~> Unit */
{ // BLOCK
val tmp_0: Any = x
when {
EQEQ(arg0 = tmp_0, arg1 = null) -> materialize<Any>()
else -> tmp_0
}
} /*as Foo<Any> */.foo()
{ // BLOCK
val tmp_1: Any = x
when {
EQEQ(arg0 = tmp_1, arg1 = null) -> materialize<Any>()
else -> tmp_1
}
} /*as Bar<Any> */.bar()
{ // BLOCK
val tmp_2: Any = x
when {
EQEQ(arg0 = tmp_2, arg1 = null) -> materialize<Any>()
else -> tmp_2
}
}.extFoo<Any>()
{ // BLOCK
val tmp_3: Any = x
when {
EQEQ(arg0 = tmp_3, arg1 = null) -> materialize<Any>()
else -> tmp_3
}
}.extBar<Any>()
}
@@ -0,0 +1,181 @@
FILE fqName:<root> fileName:/smartCastAside2.kt
FUN name:materialize visibility:public modality:FINAL <K> () returnType:K of <root>.materialize
TYPE_PARAMETER name:K index:0 variance: superTypes:[kotlin.Any?] reified:false
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun materialize <K> (): K of <root>.materialize declared in <root>'
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.Nothing origin=EXCLEXCL
<T0>: kotlin.Nothing
arg0: CONST Null type=kotlin.Nothing? value=null
CLASS INTERFACE name:Foo modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Foo<T of <root>.Foo>
TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any?] reified:false
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.Foo<T of <root>.Foo>) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Foo<T of <root>.Foo>
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
CLASS CLASS name:Bar modality:ABSTRACT 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:ABSTRACT visibility:public superTypes:[kotlin.Any]'
FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.Bar<T of <root>.Bar>) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Bar<T of <root>.Bar>
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:extFoo visibility:public modality:FINAL <T> ($receiver:<root>.Foo<T of <root>.extFoo>) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
$receiver: VALUE_PARAMETER name:<this> type:<root>.Foo<T of <root>.extFoo>
BLOCK_BODY
FUN name:extBar visibility:public modality:FINAL <T> ($receiver:<root>.Bar<T of <root>.extBar>) 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>.extBar>
BLOCK_BODY
FUN name:test_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.Any> origin=CAST typeOperand=<root>.Bar<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Foo<kotlin.Any> origin=CAST typeOperand=<root>.Foo<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: 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 abstract fun bar (): kotlin.Unit declared in <root>.Bar' type=kotlin.Unit origin=null
$this: 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
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$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: 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
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Any>? origin=CAST typeOperand=<root>.Bar<kotlin.Any>?
GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Foo<kotlin.Any>? origin=CAST typeOperand=<root>.Foo<kotlin.Any>?
GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: 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 abstract fun bar (): kotlin.Unit declared in <root>.Bar' type=kotlin.Unit origin=null
$this: 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
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any
$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: 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
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Any>? origin=CAST typeOperand=<root>.Bar<kotlin.Any>?
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Foo<kotlin.Any>? origin=CAST typeOperand=<root>.Foo<kotlin.Any>?
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: 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_0 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_0: 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_0: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public abstract fun bar (): kotlin.Unit declared in <root>.Bar' type=kotlin.Unit origin=null
$this: 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_1 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_1: 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_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: 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: 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
@@ -0,0 +1,44 @@
// ISSUE: KT-62863
fun <K> materialize(): K = null!!
interface Foo<out T> {
fun foo()
}
abstract class Bar<T : Any> {
abstract fun bar()
}
fun <T> Foo<T>.extFoo() {}
fun <T : Any> Bar<T>.extBar() {}
fun test_1(x: Any) {
x as Bar<Any>
x as Foo<Any>
x.foo()
x.bar()
x.extFoo<Any>()
x.extBar<Any>()
}
fun test_2(x: Any) {
x as Bar<Any>?
x as Foo<Any>?
x!!.foo()
x!!.bar()
x!!.extFoo<Any>()
x!!.extBar<Any>()
}
fun test_3(x: Any) {
x as Bar<Any>?
x as Foo<Any>?
(x ?: materialize()).foo()
(x ?: materialize()).bar()
(x ?: materialize()).extFoo<Any>()
(x ?: materialize()).extBar<Any>()
}
@@ -0,0 +1,77 @@
fun <K : Any?> materialize(): K {
return CHECK_NOT_NULL<Nothing>(arg0 = null)
}
interface Foo<out T : Any?> {
abstract fun foo()
}
abstract class Bar<T : Any> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
abstract fun bar()
}
fun <T : Any?> Foo<T>.extFoo() {
}
fun <T : Any> Bar<T>.extBar() {
}
fun test_1(x: Any) {
x as Bar<Any> /*~> Unit */
x as Foo<Any> /*~> Unit */
x /*as Foo<Any> */.foo()
x /*as Bar<Any> */.bar()
x /*as Foo<Any> */.extFoo<Any>()
x /*as Bar<Any> */.extBar<Any>()
}
fun test_2(x: Any) {
x as Bar<Any>? /*~> Unit */
x 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) /*as Foo<Any> */.extFoo<Any>()
CHECK_NOT_NULL<Any>(arg0 = x) /*as Bar<Any> */.extBar<Any>()
}
fun test_3(x: Any) {
x as Bar<Any>? /*~> Unit */
x as Foo<Any>? /*~> Unit */
{ // BLOCK
val tmp_0: Any = x
when {
EQEQ(arg0 = tmp_0, arg1 = null) -> materialize<Any>()
else -> tmp_0
}
} /*as Foo<Any> */.foo()
{ // BLOCK
val tmp_1: Any = x
when {
EQEQ(arg0 = tmp_1, arg1 = null) -> materialize<Any>()
else -> tmp_1
}
} /*as Bar<Any> */.bar()
{ // BLOCK
val tmp_2: Any = x
when {
EQEQ(arg0 = tmp_2, arg1 = null) -> materialize<Any>()
else -> tmp_2
}
} /*as Foo<Any> */.extFoo<Any>()
{ // BLOCK
val tmp_3: Any = x
when {
EQEQ(arg0 = tmp_3, arg1 = null) -> materialize<Any>()
else -> tmp_3
}
} /*as Bar<Any> */.extBar<Any>()
}
@@ -0,0 +1,71 @@
// CHECK:
// Mangled name: Bar
// Public signature: /Bar|null[0]
abstract 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: Bar#bar(){}
// Public signature: /Bar.bar|496682602797471549[0]
// Public signature debug description: bar(){}
abstract fun bar(): Unit
}
// CHECK:
// Mangled name: Foo
// Public signature: /Foo|null[0]
interface Foo<out T : Any?> {
// CHECK:
// Mangled name: Foo#foo(){}
// Public signature: /Foo.foo|-1041209573719867811[0]
// Public signature debug description: foo(){}
abstract fun foo(): Unit
}
// CHECK:
// Mangled name: #extBar@Bar<0:0>(){0§<kotlin.Any>}
// Public signature: /extBar|8642037032021446167[0]
// Public signature debug description: extBar@Bar<0:0>(){0§<kotlin.Any>}
fun <T : Any> Bar<T>.extBar(): Unit
// CHECK:
// Mangled name: #extFoo@Foo<0:0>(){0§<kotlin.Any?>}
// Public signature: /extFoo|-4576860830521619991[0]
// Public signature debug description: extFoo@Foo<0:0>(){0§<kotlin.Any?>}
fun <T : Any?> Foo<T>.extFoo(): Unit
// CHECK JVM_IR:
// Mangled name: #materialize(){0§<kotlin.Any?>}0:0
// Public signature: /materialize|4529465674657197020[0]
// Public signature debug description: materialize(){0§<kotlin.Any?>}0:0
// CHECK JS_IR NATIVE:
// Mangled name: #materialize(){0§<kotlin.Any?>}
// Public signature: /materialize|5983574876741311895[0]
// Public signature debug description: materialize(){0§<kotlin.Any?>}
fun <K : Any?> materialize(): K
// CHECK:
// Mangled name: #test_1(kotlin.Any){}
// Public signature: /test_1|-8508867973894375926[0]
// Public signature debug description: test_1(kotlin.Any){}
fun test_1(x: Any): Unit
// CHECK:
// Mangled name: #test_2(kotlin.Any){}
// Public signature: /test_2|4713680415350302923[0]
// Public signature debug description: test_2(kotlin.Any){}
fun test_2(x: Any): Unit
// CHECK:
// Mangled name: #test_3(kotlin.Any){}
// Public signature: /test_3|-963080351911937203[0]
// Public signature debug description: test_3(kotlin.Any){}
fun test_3(x: Any): Unit
@@ -2014,6 +2014,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -1538,6 +1538,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase {
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCasts.kt");
@@ -1762,6 +1762,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -1762,6 +1762,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest {
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -1762,6 +1762,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest {
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -1762,6 +1762,12 @@ public class ClassicNativeIrTextTestGenerated extends AbstractClassicNativeIrTex
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -1762,6 +1762,12 @@ public class FirLightTreeNativeIrTextTestGenerated extends AbstractFirLightTreeN
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {
@@ -1762,6 +1762,12 @@ public class FirPsiNativeIrTextTestGenerated extends AbstractFirPsiNativeIrTextT
runTest("compiler/testData/ir/irText/expressions/smartCastAside.kt");
}
@Test
@TestMetadata("smartCastAside2.kt")
public void testSmartCastAside2() throws Exception {
runTest("compiler/testData/ir/irText/expressions/smartCastAside2.kt");
}
@Test
@TestMetadata("smartCasts.kt")
public void testSmartCasts() throws Exception {