From 4a2f9a51237beea4d5da2eb271e32879ae28886c Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 5 Dec 2023 14:52:07 +0200 Subject: [PATCH] [FIR] Mute some tests back due to KT-64081 They were accidentally fixed with `[FIR] Process all overridden members from intersection scopes` commit, which itself introduced incorrect behavior, which was properly fixed with ... commit. So KT-64081 started to appear again --- .../codegen/bytecodeText/falseSmartCast.kt | 2 + .../smartCastInValInitialization.fir.ir.txt | 65 ++++++++++++++++ .../smartCastInValInitialization.fir.kt.txt | 25 ++++++ .../classes/smartCastInValInitialization.kt | 1 - .../expressions/smartCastAside.fir.ir.txt | 76 +++++++++++++++++++ .../expressions/smartCastAside.fir.kt.txt | 24 ++++++ .../ir/irText/expressions/smartCastAside.kt | 1 - 7 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.ir.txt create mode 100644 compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.kt.txt create mode 100644 compiler/testData/ir/irText/expressions/smartCastAside.fir.ir.txt create mode 100644 compiler/testData/ir/irText/expressions/smartCastAside.fir.kt.txt diff --git a/compiler/testData/codegen/bytecodeText/falseSmartCast.kt b/compiler/testData/codegen/bytecodeText/falseSmartCast.kt index a839cfa3870..9f35aead501 100644 --- a/compiler/testData/codegen/bytecodeText/falseSmartCast.kt +++ b/compiler/testData/codegen/bytecodeText/falseSmartCast.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_K2: JVM_IR + open class SuperFoo { public fun bar() { if (this is Foo) { diff --git a/compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.ir.txt b/compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.ir.txt new file mode 100644 index 00000000000..cf7f3a9cf7d --- /dev/null +++ b/compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.ir.txt @@ -0,0 +1,65 @@ +FILE fqName: fileName:/smartCastInValInitialization.kt + CLASS CLASS name:RootBus modality:FINAL visibility:public superTypes:[.MessageBusImpl] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.RootBus + CONSTRUCTOR visibility:public <> () returnType:.RootBus [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .MessageBusImpl' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:RootBus modality:FINAL visibility:public superTypes:[.MessageBusImpl]' + PROPERTY FAKE_OVERRIDE name:parentBus visibility:public modality:FINAL [fake_override,val] + overridden: + public final parentBus: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.MessageBusImpl) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:parentBus visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .MessageBusImpl + $this: VALUE_PARAMETER name: type:.MessageBusImpl + 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 .MessageBusImpl + $this: VALUE_PARAMETER name: 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 .MessageBusImpl + $this: VALUE_PARAMETER name: 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 .MessageBusImpl + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:MessageBusImpl modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MessageBusImpl + CONSTRUCTOR visibility:public <> () returnType:.MessageBusImpl [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MessageBusImpl modality:OPEN visibility:public superTypes:[kotlin.Any]' + PROPERTY name:parentBus visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:parentBus type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MessageBusImpl) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:parentBus visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.MessageBusImpl + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .MessageBusImpl' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:parentBus type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .MessageBusImpl declared in .MessageBusImpl.' type=.MessageBusImpl origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=.RootBus origin=CAST typeOperand=.RootBus + GET_VAR ': .MessageBusImpl declared in .MessageBusImpl' type=.MessageBusImpl origin=null + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:parentBus type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: TYPE_OP type=.RootBus origin=IMPLICIT_CAST typeOperand=.RootBus + GET_VAR ': .MessageBusImpl declared in .MessageBusImpl' type=.MessageBusImpl origin=null + value: CONST Null type=kotlin.Nothing? value=null + 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: 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: 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: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.kt.txt b/compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.kt.txt new file mode 100644 index 00000000000..f2c17e59e3c --- /dev/null +++ b/compiler/testData/ir/irText/classes/smartCastInValInitialization.fir.kt.txt @@ -0,0 +1,25 @@ +class RootBus : MessageBusImpl { + constructor() /* primary */ { + super/*MessageBusImpl*/() + /* () */ + + } + +} + +open class MessageBusImpl { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val parentBus: Any? + get + + init { + as RootBus /*~> Unit */ + /*as RootBus */.#parentBus = null + } + +} diff --git a/compiler/testData/ir/irText/classes/smartCastInValInitialization.kt b/compiler/testData/ir/irText/classes/smartCastInValInitialization.kt index d7aa58fe018..39cec492f95 100644 --- a/compiler/testData/ir/irText/classes/smartCastInValInitialization.kt +++ b/compiler/testData/ir/irText/classes/smartCastInValInitialization.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL class RootBus: MessageBusImpl() open class MessageBusImpl { diff --git a/compiler/testData/ir/irText/expressions/smartCastAside.fir.ir.txt b/compiler/testData/ir/irText/expressions/smartCastAside.fir.ir.txt new file mode 100644 index 00000000000..39db290b85a --- /dev/null +++ b/compiler/testData/ir/irText/expressions/smartCastAside.fir.ir.txt @@ -0,0 +1,76 @@ +FILE fqName: fileName:/smartCastAside.kt + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.A) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.A + 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: 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: 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: type:kotlin.Any + CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + FUN name:bar visibility:public modality:ABSTRACT <> ($this:.B) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.B + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.A) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun foo (): kotlin.Unit declared in .A + $this: VALUE_PARAMETER name: type:.A + 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 .A + $this: VALUE_PARAMETER name: 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 .A + $this: VALUE_PARAMETER name: 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 .A + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:C modality:ABSTRACT visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + FUN name:baz visibility:public modality:ABSTRACT <> ($this:.C) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.C + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.A) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun foo (): kotlin.Unit declared in .A + $this: VALUE_PARAMETER name: type:.A + 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 .A + $this: VALUE_PARAMETER name: 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 .A + $this: VALUE_PARAMETER name: 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 .A + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> (param:.B) returnType:kotlin.Unit + VALUE_PARAMETER name:param index:0 type:.B + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.C + GET_VAR 'param: .B declared in .test' type=.B origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public abstract fun foo (): kotlin.Unit declared in .A' type=kotlin.Unit origin=null + $this: TYPE_OP type=.C origin=IMPLICIT_CAST typeOperand=.C + GET_VAR 'param: .B declared in .test' type=.B origin=null + CALL 'public abstract fun bar (): kotlin.Unit declared in .B' type=kotlin.Unit origin=null + $this: GET_VAR 'param: .B declared in .test' type=.B origin=null + CALL 'public abstract fun baz (): kotlin.Unit declared in .C' type=kotlin.Unit origin=null + $this: TYPE_OP type=.C origin=IMPLICIT_CAST typeOperand=.C + GET_VAR 'param: .B declared in .test' type=.B origin=null diff --git a/compiler/testData/ir/irText/expressions/smartCastAside.fir.kt.txt b/compiler/testData/ir/irText/expressions/smartCastAside.fir.kt.txt new file mode 100644 index 00000000000..3e54b52217c --- /dev/null +++ b/compiler/testData/ir/irText/expressions/smartCastAside.fir.kt.txt @@ -0,0 +1,24 @@ +interface A { + abstract fun foo() + +} + +interface B : A { + abstract fun bar() + +} + +interface C : A { + abstract fun baz() + +} + +fun test(param: B) { + when { + param is C -> { // BLOCK + param /*as C */.foo() + param.bar() + param /*as C */.baz() + } + } +} diff --git a/compiler/testData/ir/irText/expressions/smartCastAside.kt b/compiler/testData/ir/irText/expressions/smartCastAside.kt index 8c51584fbd7..d391ec9b370 100644 --- a/compiler/testData/ir/irText/expressions/smartCastAside.kt +++ b/compiler/testData/ir/irText/expressions/smartCastAside.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL interface A { fun foo() }