diff --git a/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.fir.ir.txt b/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.fir.ir.txt new file mode 100644 index 00000000000..ede052cc495 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.fir.ir.txt @@ -0,0 +1,250 @@ +FILE fqName: fileName:/propertyInitializationAfterSmartCast.kt + CLASS CLASS name:Base_1 modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base_1 + CONSTRUCTOR visibility:public <> () returnType:.Base_1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base_1 modality:OPEN visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_1' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_1 declared in .Base_1.' type=.Base_1 origin=null + PROPERTY name:y visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_1' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_1 declared in .Base_1.' type=.Base_1 origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=.Derived_1 origin=CAST typeOperand=.Derived_1 + GET_VAR ': .Base_1 declared in .Base_1' type=.Base_1 origin=null + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: TYPE_OP type=.Derived_1 origin=IMPLICIT_CAST typeOperand=.Derived_1 + GET_VAR ': .Base_1 declared in .Base_1' type=.Base_1 origin=null + value: CONST String type=kotlin.String value="O" + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: TYPE_OP type=.Derived_1 origin=IMPLICIT_CAST typeOperand=.Derived_1 + GET_VAR ': .Base_1 declared in .Base_1' type=.Base_1 origin=null + value: CONST String type=kotlin.String value="O" + 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 CLASS name:Derived_1 modality:FINAL visibility:public superTypes:[.Base_1] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived_1 + CONSTRUCTOR visibility:public <> () returnType:.Derived_1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .Base_1' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived_1 modality:FINAL visibility:public superTypes:[.Base_1]' + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final x: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_1 + $this: VALUE_PARAMETER name: type:.Base_1 + PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final y: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_1 + $this: VALUE_PARAMETER name: type:.Base_1 + 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 .Base_1 + $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 .Base_1 + $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 .Base_1 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Base_2 modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base_2 + CONSTRUCTOR visibility:public <> () returnType:.Base_2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base_2 modality:OPEN visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_2' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_2 declared in .Base_2.' type=.Base_2 origin=null + PROPERTY name:y visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_2' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_2 declared in .Base_2.' type=.Base_2 origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=.Impl_2 origin=CAST typeOperand=.Impl_2 + GET_VAR ': .Base_2 declared in .Base_2' type=.Base_2 origin=null + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: TYPE_OP type=.Impl_2 origin=IMPLICIT_CAST typeOperand=.Impl_2 + GET_VAR ': .Base_2 declared in .Base_2' type=.Base_2 origin=null + value: CONST String type=kotlin.String value="K" + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: TYPE_OP type=.Impl_2 origin=IMPLICIT_CAST typeOperand=.Impl_2 + GET_VAR ': .Base_2 declared in .Base_2' type=.Base_2 origin=null + value: CONST String type=kotlin.String value="K" + 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 CLASS name:Derived_2 modality:OPEN visibility:public superTypes:[.Base_2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived_2 + CONSTRUCTOR visibility:public <> () returnType:.Derived_2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .Base_2' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived_2 modality:OPEN visibility:public superTypes:[.Base_2]' + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final x: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_2 + $this: VALUE_PARAMETER name: type:.Base_2 + PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final y: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_2 + $this: VALUE_PARAMETER name: type:.Base_2 + 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 .Base_2 + $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 .Base_2 + $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 .Base_2 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Impl_2 modality:FINAL visibility:public superTypes:[.Derived_2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Impl_2 + CONSTRUCTOR visibility:public <> () returnType:.Impl_2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .Derived_2' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Impl_2 modality:FINAL visibility:public superTypes:[.Derived_2]' + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final x: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Derived_2 + $this: VALUE_PARAMETER name: type:.Base_2 + PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final y: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Derived_2 + $this: VALUE_PARAMETER name: type:.Base_2 + 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 .Derived_2 + $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 .Derived_2 + $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 .Derived_2 + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:a type:.Derived_1 [val] + CONSTRUCTOR_CALL 'public constructor () declared in .Derived_1' type=.Derived_1 origin=null + VAR name:b type:.Impl_2 [val] + CONSTRUCTOR_CALL 'public constructor () declared in .Impl_2' type=.Impl_2 origin=null + VAR name:res1 type:kotlin.String [val] + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="" + other: CALL 'public final fun (): kotlin.Any? declared in .Derived_1' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val a: .Derived_1 declared in .box' type=.Derived_1 origin=null + other: CALL 'public final fun (): kotlin.Any? declared in .Impl_2' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val b: .Impl_2 declared in .box' type=.Impl_2 origin=null + VAR name:res2 type:kotlin.String [val] + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="" + other: CALL 'public final fun (): kotlin.Any? declared in .Derived_1' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val a: .Derived_1 declared in .box' type=.Derived_1 origin=null + other: CALL 'public final fun (): kotlin.Any? declared in .Impl_2' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val b: .Impl_2 declared in .box' type=.Impl_2 origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val res1: kotlin.String declared in .box' type=kotlin.String origin=null + arg1: CONST String type=kotlin.String value="OK" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Fail implicit: " + GET_VAR 'val res1: kotlin.String declared in .box' type=kotlin.String origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val res2: kotlin.String declared in .box' type=kotlin.String origin=null + arg1: CONST String type=kotlin.String value="OK" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Fail explicit: " + GET_VAR 'val res2: kotlin.String declared in .box' type=kotlin.String origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.ir.txt b/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.ir.txt new file mode 100644 index 00000000000..5507693065c --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.ir.txt @@ -0,0 +1,246 @@ +FILE fqName: fileName:/propertyInitializationAfterSmartCast.kt + CLASS CLASS name:Base_1 modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base_1 + CONSTRUCTOR visibility:public <> () returnType:.Base_1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base_1 modality:OPEN visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_1' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_1 declared in .Base_1.' type=.Base_1 origin=null + PROPERTY name:y visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_1' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_1 declared in .Base_1.' type=.Base_1 origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=.Derived_1 origin=CAST typeOperand=.Derived_1 + GET_VAR ': .Base_1 declared in .Base_1' type=.Base_1 origin=null + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Base_1 declared in .Base_1' type=.Base_1 origin=null + value: CONST String type=kotlin.String value="O" + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Base_1 declared in .Base_1' type=.Base_1 origin=null + value: CONST String type=kotlin.String value="O" + 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 CLASS name:Derived_1 modality:FINAL visibility:public superTypes:[.Base_1] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived_1 + CONSTRUCTOR visibility:public <> () returnType:.Derived_1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .Base_1' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived_1 modality:FINAL visibility:public superTypes:[.Base_1]' + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final x: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_1 + $this: VALUE_PARAMETER name: type:.Base_1 + PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final y: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_1) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_1 + $this: VALUE_PARAMETER name: type:.Base_1 + 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 .Base_1 + $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 .Base_1 + $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 .Base_1 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Base_2 modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base_2 + CONSTRUCTOR visibility:public <> () returnType:.Base_2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base_2 modality:OPEN visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_2' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_2 declared in .Base_2.' type=.Base_2 origin=null + PROPERTY name:y visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? + correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base_2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Base_2' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null + receiver: GET_VAR ': .Base_2 declared in .Base_2.' type=.Base_2 origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=.Impl_2 origin=CAST typeOperand=.Impl_2 + GET_VAR ': .Base_2 declared in .Base_2' type=.Base_2 origin=null + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Base_2 declared in .Base_2' type=.Base_2 origin=null + value: CONST String type=kotlin.String value="K" + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Any? visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Base_2 declared in .Base_2' type=.Base_2 origin=null + value: CONST String type=kotlin.String value="K" + 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 CLASS name:Derived_2 modality:OPEN visibility:public superTypes:[.Base_2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived_2 + CONSTRUCTOR visibility:public <> () returnType:.Derived_2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .Base_2' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived_2 modality:OPEN visibility:public superTypes:[.Base_2]' + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final x: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_2 + $this: VALUE_PARAMETER name: type:.Base_2 + PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final y: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Base_2 + $this: VALUE_PARAMETER name: type:.Base_2 + 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 .Base_2 + $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 .Base_2 + $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 .Base_2 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Impl_2 modality:FINAL visibility:public superTypes:[.Derived_2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Impl_2 + CONSTRUCTOR visibility:public <> () returnType:.Impl_2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .Derived_2' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Impl_2 modality:FINAL visibility:public superTypes:[.Derived_2]' + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final x: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Derived_2 + $this: VALUE_PARAMETER name: type:.Base_2 + PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final y: kotlin.Any? + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base_2) returnType:kotlin.Any? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any? declared in .Derived_2 + $this: VALUE_PARAMETER name: type:.Base_2 + 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 .Derived_2 + $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 .Derived_2 + $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 .Derived_2 + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:a type:.Derived_1 [val] + CONSTRUCTOR_CALL 'public constructor () declared in .Derived_1' type=.Derived_1 origin=null + VAR name:b type:.Impl_2 [val] + CONSTRUCTOR_CALL 'public constructor () declared in .Impl_2' type=.Impl_2 origin=null + VAR name:res1 type:kotlin.String [val] + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="" + other: CALL 'public final fun (): kotlin.Any? declared in .Derived_1' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val a: .Derived_1 declared in .box' type=.Derived_1 origin=null + other: CALL 'public final fun (): kotlin.Any? declared in .Impl_2' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val b: .Impl_2 declared in .box' type=.Impl_2 origin=null + VAR name:res2 type:kotlin.String [val] + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="" + other: CALL 'public final fun (): kotlin.Any? declared in .Derived_1' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val a: .Derived_1 declared in .box' type=.Derived_1 origin=null + other: CALL 'public final fun (): kotlin.Any? declared in .Impl_2' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 'val b: .Impl_2 declared in .box' type=.Impl_2 origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val res1: kotlin.String declared in .box' type=kotlin.String origin=null + arg1: CONST String type=kotlin.String value="OK" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Fail implicit: " + GET_VAR 'val res1: kotlin.String declared in .box' type=kotlin.String origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val res2: kotlin.String declared in .box' type=kotlin.String origin=null + arg1: CONST String type=kotlin.String value="OK" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Fail explicit: " + GET_VAR 'val res2: kotlin.String declared in .box' type=kotlin.String origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.kt b/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.kt index 9f55118fdcb..a16ba38d8a4 100644 --- a/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.kt +++ b/compiler/testData/codegen/box/smartCasts/propertyInitializationAfterSmartCast.kt @@ -1,29 +1,45 @@ // ISSUE: KT-57105 +// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION +// DUMP_IR -class RootBus: MessageBusImpl() - -open class MessageBusImpl { - val parentBus: Any? +// simpleCase +open class Base_1 { + val x: Any? + val y: Any? init { - this as RootBus - parentBus = "O" + this as Derived_1 + x = "O" + this.y = "O" } } -class RootBus2: CompositeMessageBus2() +class Derived_1: Base_1() -open class CompositeMessageBus2: MessageBusImpl2() - -open class MessageBusImpl2 { - val parentBus: Any? +// deep hierarchy +open class Base_2 { + val x: Any? + val y: Any? init { - this as RootBus2 - parentBus = "K" + this as Impl_2 + x = "K" + this.y = "K" } } +open class Derived_2: Base_2() + +class Impl_2: Derived_2() + fun box(): String { - return "" + RootBus().parentBus + RootBus2().parentBus + val a = Derived_1() + val b = Impl_2() + + val res1 = "" + a.x + b.x + val res2 = "" + a.y + b.y + + if (res1 != "OK") return "Fail implicit: $res1" + if (res2 != "OK") return "Fail explicit: $res2" + return "OK" }