diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 0b155e6fc09..1fa6c9f0fcb 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -85,6 +85,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/classes/dataClassesGeneric.kt"); } + @TestMetadata("delegatedGenericImplementation.kt") + public void testDelegatedGenericImplementation() throws Exception { + runTest("compiler/testData/ir/irText/classes/delegatedGenericImplementation.kt"); + } + @TestMetadata("delegatedImplementation.kt") public void testDelegatedImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementation.kt"); diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index e4cb79d72db..3a3afab13cb 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -42,6 +42,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererModifier import org.jetbrains.kotlin.renderer.OverrideRenderingPolicy import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.descriptorUtil.propertyIfAccessor import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.types.KotlinType @@ -320,41 +321,42 @@ class ClassGenerator( return irBlockBody } - private fun substituteOverriddenDescriptorForDelegate( - delegated: FunctionDescriptor, - overridden: FunctionDescriptor - ): FunctionDescriptor { - // TODO PropertyAccessorDescriptor doesn't support 'substitute' right now :( - return if (overridden is PropertyAccessorDescriptor) - overridden - else { - val substitutor = - TypeSubstitutor.create( - overridden.typeParameters.associate { - val delegatedDefaultType = delegated.typeParameters[it.index].defaultType - it.typeConstructor to TypeProjectionImpl(delegatedDefaultType) - } - ) - overridden.substitute(substitutor)!! + @Suppress("UNCHECKED_CAST") + private fun substituteOverriddenDescriptorForDelegate(delegated: D, overridden: D): D = + // PropertyAccessorDescriptor doesn't support 'substitute' right now, so we substitute the corresponding property instead. + when (overridden) { + is PropertyGetterDescriptor -> substituteOverriddenDescriptorForDelegate( + (delegated as PropertyGetterDescriptor).correspondingProperty, + overridden.correspondingProperty + ).getter as D + is PropertySetterDescriptor -> substituteOverriddenDescriptorForDelegate( + (delegated as PropertySetterDescriptor).correspondingProperty, + overridden.correspondingProperty + ).setter as D + else -> { + val substitutor = + TypeSubstitutor.create( + overridden.typeParameters.associate { + val delegatedDefaultType = delegated.typeParameters[it.index].defaultType + it.typeConstructor to TypeProjectionImpl(delegatedDefaultType) + } + ) + overridden.substitute(substitutor)!! as D + } } - } private fun getTypeArgumentsForOverriddenDescriptorDelegatingCall( delegated: FunctionDescriptor, overridden: FunctionDescriptor - ): Map? = - if (overridden.original.typeParameters.isEmpty()) - null - else - zipTypeParametersToDefaultTypes(overridden.original, delegated) + ): Map? { + val keys = overridden.propertyIfAccessor.original.typeParameters + if (keys.isEmpty()) return null - private fun zipTypeParametersToDefaultTypes( - keys: FunctionDescriptor, - values: FunctionDescriptor - ): Map { - val typeArguments = newHashMapWithExpectedSize(keys.typeParameters.size) - for ((i, overriddenTypeParameter) in keys.typeParameters.withIndex()) { - typeArguments[overriddenTypeParameter] = values.typeParameters[i].defaultType + val values = delegated.propertyIfAccessor.typeParameters + + val typeArguments = newHashMapWithExpectedSize(keys.size) + for ((i, overriddenTypeParameter) in keys.withIndex()) { + typeArguments[overriddenTypeParameter] = values[i].defaultType } return typeArguments } diff --git a/compiler/testData/codegen/box/delegation/genericProperty.kt b/compiler/testData/codegen/box/delegation/genericProperty.kt new file mode 100644 index 00000000000..f61a6a6e331 --- /dev/null +++ b/compiler/testData/codegen/box/delegation/genericProperty.kt @@ -0,0 +1,10 @@ +// IGNORE_BACKEND_FIR: JVM_IR + +interface I { + val T.id: T + get() = this +} + +class A(i: I) : I by i + +fun box(): String = with(A(object : I {})) { "OK".id } diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt new file mode 100644 index 00000000000..f1c4d7be158 --- /dev/null +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt @@ -0,0 +1,144 @@ +FILE fqName: fileName:/delegatedGenericImplementation.kt + CLASS INTERFACE name:IBase modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBase + TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] + FUN name:foo visibility:public modality:ABSTRACT ($this:.IBase, a:A of .IBase, b:B of .IBase.foo) returnType:kotlin.Unit + TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name:a index:0 type:A of .IBase + VALUE_PARAMETER name:b index:1 type:B of .IBase.foo + PROPERTY name:id visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IBase) returnType:kotlin.collections.Map.IBase, C of >? + correspondingProperty: PROPERTY name:id visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.IBase + PROPERTY name:x visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IBase) returnType:D of ? + correspondingProperty: PROPERTY name:x visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.IBase + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IBase, :D of ?) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:x visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name: index:0 type:D of ? + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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:Test1 modality:FINAL visibility:public superTypes:[.IBase.Test1>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test1 + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (i:.IBase.Test1>) returnType:.Test1.Test1> [primary] + VALUE_PARAMETER name:i index:0 type:.IBase.Test1> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase.Test1>]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT ($this:.IBase, a:E of .Test1, b:B of .Test1.foo) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase + TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name:a index:0 type:E of .Test1 + VALUE_PARAMETER name:b index:1 type:B of .Test1.foo + PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.Test1) returnType:kotlin.collections.Map.Test1, C of >? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] + overridden: + public abstract fun (): kotlin.collections.Map.IBase, C of >? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test1 + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.Test1) returnType:D of ? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + overridden: + public abstract fun (): D of ? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test1 + FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.Test1, :D of ?) returnType:kotlin.Unit [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + overridden: + public abstract fun (: D of ?): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.Test1 + VALUE_PARAMETER name: index:0 type:D of ? + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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:Test2 modality:FINAL visibility:public superTypes:[.IBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 + CONSTRUCTOR visibility:public <> (j:.IBase) returnType:.Test2 [primary] + VALUE_PARAMETER name:j index:0 type:.IBase + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase]' + PROPERTY name:j visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private + EXPRESSION_BODY + GET_VAR 'j: .IBase declared in .Test2.' type=.IBase origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test2) returnType:.IBase + correspondingProperty: PROPERTY name:j visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .IBase declared in .Test2' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test2, :.IBase) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:j visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test2 + VALUE_PARAMETER name: index:0 type:.IBase + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + value: GET_VAR ': .IBase declared in .Test2.' type=.IBase origin=null + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT ($this:.IBase, a:kotlin.String, b:B of .Test2.foo) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase + TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name:a index:0 type:kotlin.String + VALUE_PARAMETER name:b index:1 type:B of .Test2.foo + PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.Test2) returnType:kotlin.collections.Map>? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] + overridden: + public abstract fun (): kotlin.collections.Map.IBase, C of >? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test2 + PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.Test2) returnType:D of ? [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + overridden: + public abstract fun (): D of ? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test2 + FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.Test2, :D of ?) returnType:kotlin.Unit [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + overridden: + public abstract fun (: D of ?): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.Test2 + VALUE_PARAMETER name: index:0 type:D of ? + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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/delegatedGenericImplementation.kt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.kt new file mode 100644 index 00000000000..529f811ae3f --- /dev/null +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.kt @@ -0,0 +1,9 @@ +interface IBase { + fun foo(a: A, b: B) + val C.id: Map? + var List.x: D? +} + +class Test1(i: IBase) : IBase by i + +class Test2(var j: IBase) : IBase by j diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.txt new file mode 100644 index 00000000000..06dff777854 --- /dev/null +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.txt @@ -0,0 +1,218 @@ +FILE fqName: fileName:/delegatedGenericImplementation.kt + CLASS INTERFACE name:IBase modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBase.IBase> + TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] + FUN name:foo visibility:public modality:ABSTRACT ($this:.IBase.IBase>, a:A of .IBase, b:B of .IBase.foo) returnType:kotlin.Unit + TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.IBase.IBase> + VALUE_PARAMETER name:a index:0 type:A of .IBase + VALUE_PARAMETER name:b index:1 type:B of .IBase.foo + PROPERTY name:id visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>, $receiver:C of .IBase.) returnType:kotlin.collections.Map.IBase, C of .IBase.>? + correspondingProperty: PROPERTY name:id visibility:public modality:ABSTRACT [val] + TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.IBase.IBase> + $receiver: VALUE_PARAMETER name: type:C of .IBase. + PROPERTY name:x visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>, $receiver:kotlin.collections.List.IBase.>) returnType:D of .IBase.? + correspondingProperty: PROPERTY name:x visibility:public modality:ABSTRACT [var] + TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.IBase.IBase> + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.IBase.> + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>, $receiver:kotlin.collections.List.IBase.>, :D of .IBase.?) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:x visibility:public modality:ABSTRACT [var] + TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.IBase.IBase> + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.IBase.> + VALUE_PARAMETER name: index:0 type:D of .IBase.? + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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:Test1 modality:FINAL visibility:public superTypes:[.IBase.Test1>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test1.Test1> + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (i:.IBase.Test1>) returnType:.Test1.Test1> [primary] + VALUE_PARAMETER name:i index:0 type:.IBase.Test1> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase.Test1>]' + FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'i: .IBase.Test1> declared in .Test1.' type=.IBase.Test1> origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN ($this:.Test1.Test1>, a:E of .Test1, b:B of .Test1.foo) returnType:kotlin.Unit + overridden: + public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase + TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Test1.Test1> + VALUE_PARAMETER name:a index:0 type:E of .Test1 + VALUE_PARAMETER name:b index:1 type:B of .Test1.foo + BLOCK_BODY + CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : B of .Test1.foo + $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.foo' type=.Test1.Test1> origin=null + a: GET_VAR 'a: E of .Test1 declared in .Test1.foo' type=E of .Test1 origin=null + b: GET_VAR 'b: B of .Test1.foo declared in .Test1.foo' type=B of .Test1.foo origin=null + PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test1.Test1>, $receiver:C of .Test1.) returnType:kotlin.collections.Map.Test1, C of .Test1.>? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test1.Test1> + $receiver: VALUE_PARAMETER name: type:C of .Test1. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test1, C of .Test1.>? declared in .Test1' + CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test1, C of .Test1.>? origin=null + : C of .Test1. + $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null + $receiver: GET_VAR ': C of .Test1. declared in .Test1.' type=C of .Test1. origin=null + PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test1.Test1>, $receiver:kotlin.collections.List.Test1.>) returnType:D of .Test1.? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + overridden: + public abstract fun (): D of .IBase.? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test1.Test1> + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.Test1.> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): D of .Test1.? declared in .Test1' + CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test1.? origin=null + : D of .Test1. + $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null + $receiver: GET_VAR ': kotlin.collections.List.Test1.> declared in .Test1.' type=kotlin.collections.List.Test1.> origin=null + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test1.Test1>, $receiver:kotlin.collections.List.Test1.>, :D of .Test1.?) returnType:kotlin.Unit + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + overridden: + public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.Test1.Test1> + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.Test1.> + VALUE_PARAMETER name: index:0 type:D of .Test1.? + BLOCK_BODY + CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : D of .Test1. + $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null + $receiver: GET_VAR ': kotlin.collections.List.Test1.> declared in .Test1.' type=kotlin.collections.List.Test1.> origin=null + : GET_VAR ': D of .Test1.? declared in .Test1.' type=D of .Test1.? origin=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 [fake_override,operator] declared in .IBase + $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 [fake_override] declared in .IBase + $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 [fake_override] declared in .IBase + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 + CONSTRUCTOR visibility:public <> (j:.IBase) returnType:.Test2 [primary] + VALUE_PARAMETER name:j index:0 type:.IBase + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase]' + PROPERTY name:j visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private + EXPRESSION_BODY + GET_VAR 'j: .IBase declared in .Test2.' type=.IBase origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test2) returnType:.IBase + correspondingProperty: PROPERTY name:j visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .IBase declared in .Test2' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test2, :.IBase) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:j visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test2 + VALUE_PARAMETER name: index:0 type:.IBase + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + value: GET_VAR ': .IBase declared in .Test2.' type=.IBase origin=null + FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final] + EXPRESSION_BODY + GET_VAR 'j: .IBase declared in .Test2.' type=.IBase origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN ($this:.Test2, a:kotlin.String, b:B of .Test2.foo) returnType:kotlin.Unit + overridden: + public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase + TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Test2 + VALUE_PARAMETER name:a index:0 type:kotlin.String + VALUE_PARAMETER name:b index:1 type:B of .Test2.foo + BLOCK_BODY + CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : B of .Test2.foo + $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.foo' type=.Test2 origin=null + a: GET_VAR 'a: kotlin.String declared in .Test2.foo' type=kotlin.String origin=null + b: GET_VAR 'b: B of .Test2.foo declared in .Test2.foo' type=B of .Test2.foo origin=null + PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, $receiver:C of .Test2.) returnType:kotlin.collections.Map.Test2.>? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test2 + $receiver: VALUE_PARAMETER name: type:C of .Test2. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test2.>? declared in .Test2' + CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test2.>? origin=null + : C of .Test2. + $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + $receiver: GET_VAR ': C of .Test2. declared in .Test2.' type=C of .Test2. origin=null + PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, $receiver:kotlin.collections.List.Test2.>) returnType:D of .Test2.? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + overridden: + public abstract fun (): D of .IBase.? declared in .IBase + $this: VALUE_PARAMETER name: type:.Test2 + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.Test2.> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): D of .Test2.? declared in .Test2' + CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test2.? origin=null + : D of .Test2. + $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + $receiver: GET_VAR ': kotlin.collections.List.Test2.> declared in .Test2.' type=kotlin.collections.List.Test2.> origin=null + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, $receiver:kotlin.collections.List.Test2.>, :D of .Test2.?) returnType:kotlin.Unit + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + overridden: + public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.Test2 + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.Test2.> + VALUE_PARAMETER name: index:0 type:D of .Test2.? + BLOCK_BODY + CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : D of .Test2. + $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + $receiver: GET_VAR ': kotlin.collections.List.Test2.> declared in .Test2.' type=kotlin.collections.List.Test2.> origin=null + : GET_VAR ': D of .Test2.? declared in .Test2.' type=D of .Test2.? origin=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 [fake_override,operator] declared in .IBase + $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 [fake_override] declared in .IBase + $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 [fake_override] declared in .IBase + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 71bb357541c..d08b896d524 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -9952,6 +9952,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/delegation/diamond2.kt"); } + @TestMetadata("genericProperty.kt") + public void testGenericProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegation/genericProperty.kt"); + } + @TestMetadata("hiddenSuperOverrideIn1.0.kt") public void testHiddenSuperOverrideIn1_0() throws Exception { runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index bc78f235e49..98062f8d9d4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -9957,6 +9957,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/delegation/diamond2.kt"); } + @TestMetadata("genericProperty.kt") + public void testGenericProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegation/genericProperty.kt"); + } + @TestMetadata("hiddenSuperOverrideIn1.0.kt") public void testHiddenSuperOverrideIn1_0() throws Exception { runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 3a89f00022e..2ab873c530e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -8802,6 +8802,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/delegation/diamond2.kt"); } + @TestMetadata("genericProperty.kt") + public void testGenericProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegation/genericProperty.kt"); + } + @TestMetadata("hiddenSuperOverrideIn1.0.kt") public void testHiddenSuperOverrideIn1_0() throws Exception { runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 0c6a9365383..89177191754 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -8802,6 +8802,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/delegation/diamond2.kt"); } + @TestMetadata("genericProperty.kt") + public void testGenericProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegation/genericProperty.kt"); + } + @TestMetadata("hiddenSuperOverrideIn1.0.kt") public void testHiddenSuperOverrideIn1_0() throws Exception { runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index e1ff3bfbb18..2d2d50fb570 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -85,6 +85,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/classes/dataClassesGeneric.kt"); } + @TestMetadata("delegatedGenericImplementation.kt") + public void testDelegatedGenericImplementation() throws Exception { + runTest("compiler/testData/ir/irText/classes/delegatedGenericImplementation.kt"); + } + @TestMetadata("delegatedImplementation.kt") public void testDelegatedImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementation.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 85f5303a1ad..ec47d57bd7a 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -7617,6 +7617,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/delegationWithPrivateConstructor.kt"); } + @TestMetadata("genericProperty.kt") + public void testGenericProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegation/genericProperty.kt"); + } + @TestMetadata("hiddenSuperOverrideIn1.0.kt") public void testHiddenSuperOverrideIn1_0() throws Exception { runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index c4b2362a29c..70235fea987 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -8692,6 +8692,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/delegationWithPrivateConstructor.kt"); } + @TestMetadata("genericProperty.kt") + public void testGenericProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegation/genericProperty.kt"); + } + @TestMetadata("hiddenSuperOverrideIn1.0.kt") public void testHiddenSuperOverrideIn1_0() throws Exception { runTest("compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt");