From 968ecadff2555ae4ad0a30fb26e87ddeda6f5d33 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Thu, 25 Jan 2024 23:41:31 +0100 Subject: [PATCH] [FIR2IR] Erasure type of parameter of delegated property in K1 manner Add `shouldEraseType` to `Fir2IrConversionScope` ^KT-62884 Fixed --- ...LFirBlackBoxCodegenBasedTestGenerated.java | 6 + ...rsedBlackBoxCodegenBasedTestGenerated.java | 6 + .../fir/backend/Fir2IrComponentsStorage.kt | 2 +- .../fir/backend/Fir2IrConversionScope.kt | 14 ++ .../kotlin/fir/backend/Fir2IrTypeConverter.kt | 19 +- ...LightTreeBlackBoxCodegenTestGenerated.java | 6 + ...hIrFakeOverrideGeneratorTestGenerated.java | 6 + .../FirPsiBlackBoxCodegenTestGenerated.java | 6 + ...ypeParameterInDelegatedProperty.fir.ir.txt | 169 +++++++++++++++++ .../typeParameterInDelegatedProperty.ir.txt | 175 ++++++++++++++++++ .../typeParameterInDelegatedProperty.kt | 41 ++++ .../deepGenericDelegatedProperty.jvm_abi.txt | 43 ----- .../deepGenericDelegatedProperty.kt | 1 - .../genericDelegatedDeepProperty.fir.ir.txt | 122 ++++++------ .../genericDelegatedDeepProperty.fir.kt.txt | 31 ++-- .../JvmAbiConsistencyTestBoxGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 6 + ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 5 + 19 files changed, 550 insertions(+), 120 deletions(-) create mode 100644 compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.fir.ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt delete mode 100644 compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.jvm_abi.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java index cc2b98a9e7c..8828c9e5136 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java @@ -16106,6 +16106,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java index c2ea8ffd6c8..369033d43e2 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java @@ -16106,6 +16106,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrComponentsStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrComponentsStorage.kt index dfa04139831..9389ff463bb 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrComponentsStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrComponentsStorage.kt @@ -60,7 +60,7 @@ class Fir2IrComponentsStorage( override val irProviders: List = listOf(FirIrProvider(this)) - override val typeConverter: Fir2IrTypeConverter = Fir2IrTypeConverter(this) + override val typeConverter: Fir2IrTypeConverter = Fir2IrTypeConverter(this, conversionScope) val fir2IrVisitor: Fir2IrVisitor = Fir2IrVisitor(this, conversionScope) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt index 7686d7a5e9c..ff04aa44abb 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt @@ -6,7 +6,10 @@ package org.jetbrains.kotlin.fir.backend import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.utils.isExtension +import org.jetbrains.kotlin.fir.declarations.utils.isLocal import org.jetbrains.kotlin.fir.expressions.FirReturnExpression +import org.jetbrains.kotlin.fir.types.ConeTypeParameterType import org.jetbrains.kotlin.ir.builders.Scope import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.symbols.* @@ -235,4 +238,15 @@ class Fir2IrConversionScope(val configuration: Fir2IrConfiguration) { fun lastWhenSubject(): IrVariable = whenSubjectVariableStack.last() fun lastSafeCallSubject(): IrVariable = safeCallSubjectVariableStack.last() + + fun shouldEraseType(type: ConeTypeParameterType): Boolean = containingFirClassStack.asReversed().any { clazz -> + if (clazz !is FirAnonymousObject && !clazz.isLocal) return@any false + + val typeParameterSymbol = type.lookupTag.typeParameterSymbol + if (typeParameterSymbol.containingDeclarationSymbol.fir.let { it !is FirProperty || it.delegate == null || !it.isExtension }) { + return@any false + } + + return@any clazz.typeParameters.any { it.symbol === typeParameterSymbol } + } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 3a5ffa299ce..0d7dbcd76a8 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -29,7 +29,8 @@ import org.jetbrains.kotlin.types.TypeApproximatorConfiguration import org.jetbrains.kotlin.types.Variance class Fir2IrTypeConverter( - private val components: Fir2IrComponents + private val components: Fir2IrComponents, + private val conversionScope: Fir2IrConversionScope, ) : Fir2IrComponents by components { internal val classIdToSymbolMap by lazy { @@ -157,6 +158,14 @@ class Fir2IrTypeConverter( } val expandedType = fullyExpandedType(session) val approximatedType = approximateType(expandedType) + + if (approximatedType is ConeTypeParameterType && conversionScope.shouldEraseType(approximatedType)) { + // This hack is about type parameter leak in case of generic delegated property + // It probably will be prohibited after 2.0 + // For more details see KT-24643 + return approximateUpperBounds(approximatedType.lookupTag.typeParameterSymbol.resolvedBounds) + } + IrSimpleTypeImpl( irSymbol, hasQuestionMark = approximatedType.isMarkedNullable, @@ -246,6 +255,14 @@ class Fir2IrTypeConverter( upperBound.typeArguments.single().kind == ProjectionKind.OUT } + private fun approximateUpperBounds(resolvedBounds: List): IrType { + val commonSupertype = session.typeContext.commonSuperTypeOrNull(resolvedBounds.map { it.type })!! + val resultType = (commonSupertype as? ConeClassLikeType)?.replaceArgumentsWithStarProjections() + ?: commonSupertype + val approximatedType = (commonSupertype as? ConeSimpleKotlinType)?.let { approximateType(it) } ?: resultType + return approximatedType.toIrType() + } + private fun ConeFlexibleType.isMutabilityFlexible(): Boolean { val lowerFqName = lowerBound.classId?.asSingleFqName() ?: return false val upperFqName = upperBound.classId?.asSingleFqName() ?: return false diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index eaabf19ed20..52c13160302 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -16107,6 +16107,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index 4f52ca095b0..0867551e905 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -16107,6 +16107,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 7c533fcf3a7..a778ffa8d73 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -16107,6 +16107,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.fir.ir.txt b/compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.fir.ir.txt new file mode 100644 index 00000000000..e81811f00eb --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.fir.ir.txt @@ -0,0 +1,169 @@ +FILE fqName: fileName:/typeParameterInDelegatedProperty.kt + CLASS INTERFACE name:IDelegate modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IDelegate.IDelegate> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + FUN name:getValue visibility:public modality:ABSTRACT <> ($this:.IDelegate.IDelegate>, t:T of .IDelegate, p:kotlin.reflect.KProperty<*>) returnType:T of .IDelegate [operator] + $this: VALUE_PARAMETER name: type:.IDelegate.IDelegate> + VALUE_PARAMETER name:t index:0 type:T of .IDelegate + VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> + 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 + PROPERTY name:property visibility:public modality:FINAL [delegated,val] + FIELD PROPERTY_DELEGATE name:property$delegate type:.property$delegate..> visibility:private [final,static] + EXPRESSION_BODY + BLOCK type=.property$delegate..> origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.property$delegate..> + CONSTRUCTOR visibility:public <> () returnType:.property$delegate. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate]' + FUN name:getValue visibility:public modality:OPEN <> ($this:.property$delegate..>, t:kotlin.Any?, p:kotlin.reflect.KProperty<*>) returnType:kotlin.Any? [operator] + overridden: + public abstract fun getValue (t: T of .IDelegate, p: kotlin.reflect.KProperty<*>): T of .IDelegate declared in .IDelegate + $this: VALUE_PARAMETER name: type:.property$delegate..> + VALUE_PARAMETER name:t index:0 type:kotlin.Any? + VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun getValue (t: kotlin.Any?, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .property$delegate.' + GET_VAR 't: kotlin.Any? declared in .property$delegate..getValue' type=kotlin.Any? 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 declared in .IDelegate + $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 .IDelegate + $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 .IDelegate + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () declared in .property$delegate.' type=.property$delegate..> origin=OBJECT_LITERAL + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL ($receiver:T of .) returnType:T of . + correspondingProperty: PROPERTY name:property visibility:public modality:FINAL [delegated,val] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + $receiver: VALUE_PARAMETER name: type:T of . + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of . declared in ' + CALL 'public open fun getValue (t: kotlin.Any?, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .property$delegate.' type=T of . origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:property$delegate type:.property$delegate..> visibility:private [final,static]' type=.property$delegate..> origin=null + t: GET_VAR ': T of . declared in .' type=T of . origin=null + p: PROPERTY_REFERENCE 'public final property: T of .' field=null getter='public final fun (): T of . declared in ' setter=null type=kotlin.reflect.KProperty1., T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE + <1>: T of . + PROPERTY name:property2 visibility:public modality:FINAL [delegated,val] + FIELD PROPERTY_DELEGATE name:property2$delegate type:.IDelegate.> visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run declared in kotlin' type=.IDelegate.> origin=null + : .IDelegate.> + block: FUN_EXPR type=kotlin.Function0<.IDelegate.>> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:.IDelegate.> + BLOCK_BODY + FUN LOCAL_FUNCTION name:test visibility:local modality:FINAL <> (t:T of .) returnType:T of . + VALUE_PARAMETER name:t index:0 type:T of . + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun test (t: T of .): T of . declared in .property2$delegate.' + GET_VAR 't: T of . declared in .property2$delegate..test' type=T of . origin=null + RETURN type=kotlin.Nothing from='local final fun (): .IDelegate.> declared in .property2$delegate' + BLOCK type=.property2$delegate...> origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.property2$delegate...> + CONSTRUCTOR visibility:public <> () returnType:.property2$delegate.. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate]' + FUN name:getValue visibility:public modality:OPEN <> ($this:.property2$delegate...>, t:kotlin.Any?, p:kotlin.reflect.KProperty<*>) returnType:kotlin.Any? [operator] + overridden: + public abstract fun getValue (t: T of .IDelegate, p: kotlin.reflect.KProperty<*>): T of .IDelegate declared in .IDelegate + $this: VALUE_PARAMETER name: type:.property2$delegate...> + VALUE_PARAMETER name:t index:0 type:kotlin.Any? + VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun getValue (t: kotlin.Any?, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .property2$delegate..' + CALL 'local final fun test (t: T of .): T of . declared in .property2$delegate.' type=kotlin.Any? origin=null + t: GET_VAR 't: kotlin.Any? declared in .property2$delegate...getValue' type=kotlin.Any? 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 declared in .IDelegate + $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 .IDelegate + $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 .IDelegate + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () declared in .property2$delegate..' type=.property2$delegate...> origin=OBJECT_LITERAL + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL ($receiver:T of .) returnType:T of . + correspondingProperty: PROPERTY name:property2 visibility:public modality:FINAL [delegated,val] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + $receiver: VALUE_PARAMETER name: type:T of . + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of . declared in ' + CALL 'public abstract fun getValue (t: T of .IDelegate, p: kotlin.reflect.KProperty<*>): T of .IDelegate declared in .IDelegate' type=T of . origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:property2$delegate type:.IDelegate.> visibility:private [final,static]' type=.IDelegate.> origin=null + t: GET_VAR ': T of . declared in .' type=T of . origin=null + p: PROPERTY_REFERENCE 'public final property2: T of .' field=null getter='public final fun (): T of . declared in ' setter=null type=kotlin.reflect.KProperty1., T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE + <1>: T of . + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:superInterfaces type:kotlin.Array [val] + TYPE_OP type=@[FlexibleArrayElementVariance] kotlin.Array origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleArrayElementVariance] kotlin.Array + CALL 'public open fun getGenericInterfaces (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array? declared in java.lang.Class' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array? origin=null + $this: CALL 'public open fun forName (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.Class<*>? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.Class<*>? origin=null + p0: CONST String type=kotlin.String value="TypeParameterInDelegatedPropertyKt$property$2" + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=null + $this: CALL 'public final fun contains (other: kotlin.CharSequence, ignoreCase: kotlin.Boolean): kotlin.Boolean declared in kotlin.text' type=kotlin.Boolean origin=null + $receiver: CALL 'public open fun toString (): kotlin.String declared in java.lang.reflect.Type' type=kotlin.String origin=null + $this: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any + CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=java.lang.reflect.Type origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val superInterfaces: kotlin.Array declared in .box' type=kotlin.Array origin=null + index: CONST Int type=kotlin.Int value=0 + other: CONST String type=kotlin.String value="IDelegate" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + VAR name:superInterfaces2 type:kotlin.Array [val] + TYPE_OP type=@[FlexibleArrayElementVariance] kotlin.Array origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleArrayElementVariance] kotlin.Array + CALL 'public open fun getGenericInterfaces (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array? declared in java.lang.Class' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array? origin=null + $this: CALL 'public open fun forName (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.Class<*>? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.Class<*>? origin=null + p0: CONST String type=kotlin.String value="TypeParameterInDelegatedPropertyKt$property2$2$1" + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=null + $this: CALL 'public final fun contains (other: kotlin.CharSequence, ignoreCase: kotlin.Boolean): kotlin.Boolean declared in kotlin.text' type=kotlin.Boolean origin=null + $receiver: CALL 'public open fun toString (): kotlin.String declared in java.lang.reflect.Type' type=kotlin.String origin=null + $this: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any + CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=java.lang.reflect.Type origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val superInterfaces2: kotlin.Array declared in .box' type=kotlin.Array origin=null + index: CONST Int type=kotlin.Int value=0 + other: CONST String type=kotlin.String value="IDelegate" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + 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: CALL 'public final fun (): T of . declared in ' type=kotlin.String origin=GET_PROPERTY + : kotlin.String + $receiver: CONST String type=kotlin.String value="OK" + arg1: CONST String type=kotlin.String value="OK" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + 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/delegatedProperty/typeParameterInDelegatedProperty.ir.txt b/compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.ir.txt new file mode 100644 index 00000000000..f29982a1fb2 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.ir.txt @@ -0,0 +1,175 @@ +FILE fqName: fileName:/typeParameterInDelegatedProperty.kt + CLASS INTERFACE name:IDelegate modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IDelegate.IDelegate> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + FUN name:getValue visibility:public modality:ABSTRACT <> ($this:.IDelegate.IDelegate>, t:T of .IDelegate, p:kotlin.reflect.KProperty<*>) returnType:T of .IDelegate [operator] + $this: VALUE_PARAMETER name: type:.IDelegate.IDelegate> + VALUE_PARAMETER name:t index:0 type:T of .IDelegate + VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> + 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 + PROPERTY name:property visibility:public modality:FINAL [delegated,val] + FIELD PROPERTY_DELEGATE name:property$delegate type:.property$delegate. visibility:private [final,static] + EXPRESSION_BODY + BLOCK type=.property$delegate. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.property$delegate. + CONSTRUCTOR visibility:public <> () returnType:.property$delegate. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate]' + FUN name:getValue visibility:public modality:OPEN <> ($this:.property$delegate., t:kotlin.Any?, p:kotlin.reflect.KProperty<*>) returnType:kotlin.Any? [operator] + overridden: + public abstract fun getValue (t: T of .IDelegate, p: kotlin.reflect.KProperty<*>): T of .IDelegate declared in .IDelegate + $this: VALUE_PARAMETER name: type:.property$delegate. + VALUE_PARAMETER name:t index:0 type:kotlin.Any? + VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun getValue (t: kotlin.Any?, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .property$delegate.' + TYPE_OP type=kotlin.Any? origin=IMPLICIT_CAST typeOperand=kotlin.Any? + GET_VAR 't: kotlin.Any? declared in .property$delegate..getValue' type=kotlin.Any? 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 declared in .IDelegate + $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 .IDelegate + $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 .IDelegate + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () declared in .property$delegate.' type=.property$delegate. origin=OBJECT_LITERAL + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL ($receiver:T of .) returnType:T of . + correspondingProperty: PROPERTY name:property visibility:public modality:FINAL [delegated,val] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + $receiver: VALUE_PARAMETER name: type:T of . + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of . declared in ' + CALL 'public open fun getValue (t: kotlin.Any?, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .property$delegate.' type=T of . origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:property$delegate type:.property$delegate. visibility:private [final,static]' type=.property$delegate. origin=null + t: GET_VAR ': T of . declared in .' type=T of . origin=null + p: PROPERTY_REFERENCE 'public final property: T of .' field=null getter='public final fun (): T of . declared in ' setter=null type=kotlin.reflect.KProperty1., T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE + <1>: T of . + PROPERTY name:property2 visibility:public modality:FINAL [delegated,val] + FIELD PROPERTY_DELEGATE name:property2$delegate type:.IDelegate visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run declared in kotlin' type=.IDelegate origin=null + : .IDelegate + block: FUN_EXPR type=kotlin.Function0<.IDelegate> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:.IDelegate + BLOCK_BODY + FUN LOCAL_FUNCTION name:test visibility:local modality:FINAL <> (t:kotlin.Any?) returnType:kotlin.Any? + VALUE_PARAMETER name:t index:0 type:kotlin.Any? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun test (t: kotlin.Any?): kotlin.Any? declared in .property2$delegate.' + TYPE_OP type=kotlin.Any? origin=IMPLICIT_CAST typeOperand=kotlin.Any? + GET_VAR 't: kotlin.Any? declared in .property2$delegate..test' type=kotlin.Any? origin=null + RETURN type=kotlin.Nothing from='local final fun (): .IDelegate declared in .property2$delegate' + BLOCK type=.property2$delegate.. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.property2$delegate.. + CONSTRUCTOR visibility:public <> () returnType:.property2$delegate.. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate]' + FUN name:getValue visibility:public modality:OPEN <> ($this:.property2$delegate.., t:kotlin.Any?, p:kotlin.reflect.KProperty<*>) returnType:kotlin.Any? [operator] + overridden: + public abstract fun getValue (t: T of .IDelegate, p: kotlin.reflect.KProperty<*>): T of .IDelegate declared in .IDelegate + $this: VALUE_PARAMETER name: type:.property2$delegate.. + VALUE_PARAMETER name:t index:0 type:kotlin.Any? + VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun getValue (t: kotlin.Any?, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .property2$delegate..' + TYPE_OP type=kotlin.Any? origin=IMPLICIT_CAST typeOperand=kotlin.Any? + CALL 'local final fun test (t: kotlin.Any?): kotlin.Any? declared in .property2$delegate.' type=kotlin.Any? origin=null + t: TYPE_OP type=kotlin.Any? origin=IMPLICIT_CAST typeOperand=kotlin.Any? + GET_VAR 't: kotlin.Any? declared in .property2$delegate...getValue' type=kotlin.Any? 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 declared in .IDelegate + $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 .IDelegate + $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 .IDelegate + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () declared in .property2$delegate..' type=.property2$delegate.. origin=OBJECT_LITERAL + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL ($receiver:T of .) returnType:T of . + correspondingProperty: PROPERTY name:property2 visibility:public modality:FINAL [delegated,val] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + $receiver: VALUE_PARAMETER name: type:T of . + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of . declared in ' + CALL 'public abstract fun getValue (t: T of .IDelegate, p: kotlin.reflect.KProperty<*>): T of .IDelegate declared in .IDelegate' type=T of . origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:property2$delegate type:.IDelegate visibility:private [final,static]' type=.IDelegate origin=null + t: GET_VAR ': T of . declared in .' type=T of . origin=null + p: PROPERTY_REFERENCE 'public final property2: T of .' field=null getter='public final fun (): T of . declared in ' setter=null type=kotlin.reflect.KProperty1., T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE + <1>: T of . + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:superInterfaces type:kotlin.Array [val] + TYPE_OP type=kotlin.Array origin=IMPLICIT_CAST typeOperand=kotlin.Array + TYPE_OP type=kotlin.Array origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array + CALL 'public open fun getGenericInterfaces (): @[FlexibleNullability] kotlin.Array? declared in java.lang.Class' type=@[FlexibleNullability] kotlin.Array? origin=null + $this: TYPE_OP type=java.lang.Class<*> origin=IMPLICIT_NOTNULL typeOperand=java.lang.Class<*> + CALL 'public open fun forName (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.Class<*>? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.Class<*>? origin=null + p0: CONST String type=kotlin.String value="TypeParameterInDelegatedPropertyKt$property$2" + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCL + $this: CALL 'public final fun contains (other: kotlin.CharSequence, ignoreCase: kotlin.Boolean): kotlin.Boolean declared in kotlin.text' type=kotlin.Boolean origin=null + $receiver: CALL 'public open fun toString (): kotlin.String declared in java.lang.reflect.Type' type=kotlin.String origin=null + $this: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=java.lang.reflect.Type origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val superInterfaces: kotlin.Array declared in .box' type=kotlin.Array origin=null + index: CONST Int type=kotlin.Int value=0 + other: CONST String type=kotlin.String value="IDelegate" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + VAR name:superInterfaces2 type:kotlin.Array [val] + TYPE_OP type=kotlin.Array origin=IMPLICIT_CAST typeOperand=kotlin.Array + TYPE_OP type=kotlin.Array origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array + CALL 'public open fun getGenericInterfaces (): @[FlexibleNullability] kotlin.Array? declared in java.lang.Class' type=@[FlexibleNullability] kotlin.Array? origin=null + $this: TYPE_OP type=java.lang.Class<*> origin=IMPLICIT_NOTNULL typeOperand=java.lang.Class<*> + CALL 'public open fun forName (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.Class<*>? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.Class<*>? origin=null + p0: CONST String type=kotlin.String value="TypeParameterInDelegatedPropertyKt$property2$2$1" + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCL + $this: CALL 'public final fun contains (other: kotlin.CharSequence, ignoreCase: kotlin.Boolean): kotlin.Boolean declared in kotlin.text' type=kotlin.Boolean origin=null + $receiver: CALL 'public open fun toString (): kotlin.String declared in java.lang.reflect.Type' type=kotlin.String origin=null + $this: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=java.lang.reflect.Type origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val superInterfaces2: kotlin.Array declared in .box' type=kotlin.Array origin=null + index: CONST Int type=kotlin.Int value=0 + other: CONST String type=kotlin.String value="IDelegate" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + 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: CALL 'public final fun (): T of . declared in ' type=kotlin.String origin=GET_PROPERTY + : kotlin.String + $receiver: CONST String type=kotlin.String value="OK" + arg1: CONST String type=kotlin.String value="OK" + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + 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/delegatedProperty/typeParameterInDelegatedProperty.kt b/compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt new file mode 100644 index 00000000000..d78f81359f1 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt @@ -0,0 +1,41 @@ +// TARGET_BACKEND: JVM_IR +// WITH_STDLIB +// DUMP_IR +// ISSUE: KT-62884 + +import kotlin.reflect.KProperty +import java.lang.reflect.Type + +interface IDelegate { + operator fun getValue(t: T, p: KProperty<*>): T +} + +val T.property by object : IDelegate { + override fun getValue(t: T, p: KProperty<*>): T { + return t + } +} + +val T.property2 by run> { + fun test(t: T): T { + return t + } + + object : IDelegate { + override fun getValue(t: T, p: KProperty<*>): T { + return test(t) + } + } +} + +fun box(): String { + val superInterfaces: Array = Class.forName("TypeParameterInDelegatedPropertyKt\$property\$2").getGenericInterfaces() + if (!superInterfaces[0].toString().contains("IDelegate")) return "FAIL" + + val superInterfaces2: Array = Class.forName("TypeParameterInDelegatedPropertyKt\$property2\$2\$1").getGenericInterfaces() + if (!superInterfaces2[0].toString().contains("IDelegate")) return "FAIL" + + if ("OK".property2 != "OK") return "FAIL" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.jvm_abi.txt b/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.jvm_abi.txt deleted file mode 100644 index 685c1b02ac6..00000000000 --- a/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.jvm_abi.txt +++ /dev/null @@ -1,43 +0,0 @@ -MODULE lib - CLASS LibKt$additionalText$2.class - Property: class.signature - K1 - Ljava/lang/Object;LIDelegate1;>;LP;>; - K2 - Ljava/lang/Object;LIDelegate1;>;LP;>; - METHOD getValue(LValue;Lkotlin/reflect/KProperty;)LP; - Property: method.signature - K1 - (LValue;>;Lkotlin/reflect/KProperty<*>;)LP; - K2 - (LValue;>;Lkotlin/reflect/KProperty<*>;)LP; - CLASS LibKt$additionalText$2$deepO$2.class - Property: class.signature - K1 - Ljava/lang/Object;LIDelegate1;>;Ljava/lang/Object;>; - K2 - Ljava/lang/Object;LIDelegate1;>;TT;>; - METHOD getValue(LValue;Lkotlin/reflect/KProperty;)Ljava/lang/Object; - Property: method.signature - K1 - (LValue;>;Lkotlin/reflect/KProperty<*>;)Ljava/lang/Object; - K2 - (LValue;>;Lkotlin/reflect/KProperty<*>;)TT; - CLASS LibKt$additionalText$2$deepK$2.class - Property: class.signature - K1 - Ljava/lang/Object;LIDelegate1;>;Ljava/lang/Object;>; - K2 - Ljava/lang/Object;LIDelegate1;>;TT;>; - METHOD getValue(LValue;Lkotlin/reflect/KProperty;)Ljava/lang/Object; - Property: method.signature - K1 - (LValue;>;Lkotlin/reflect/KProperty<*>;)Ljava/lang/Object; - K2 - (LValue;>;Lkotlin/reflect/KProperty<*>;)TT; - METHOD qux22(LIR;)Ljava/lang/Object; - Property: method.signature - K1 - ;>(TF22T;)Ljava/lang/Object; - K2 - ;>(TF22T;)TT; diff --git a/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt b/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt index 5ae9570186f..4138991bd02 100644 --- a/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt +++ b/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt @@ -2,7 +2,6 @@ // SKIP_MANGLE_VERIFICATION //For KT-6020 // KT-24643: language version in K2 is >= 1.8 -// JVM_ABI_K1_K2_DIFF: KT-62884 // MODULE: lib // FILE: lib.kt diff --git a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.ir.txt b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.ir.txt index 7c6a417645e..4d2609a0512 100644 --- a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.ir.txt +++ b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.ir.txt @@ -201,12 +201,12 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt FIELD PROPERTY_DELEGATE name:additionalText$delegate type:.additionalText$delegate..> visibility:private [final,static] EXPRESSION_BODY BLOCK type=.additionalText$delegate..> origin=OBJECT_LITERAL - CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value., .CR.>>, .P., T of .>>] + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value.CR>, .P>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.additionalText$delegate..> - CONSTRUCTOR visibility:public <> () returnType:.additionalText$delegate..> [primary] + CONSTRUCTOR visibility:public <> () returnType:.additionalText$delegate. [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value., .CR.>>, .P., T of .>>]' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value.CR>, .P>]' FUN name:qux11 visibility:public modality:FINAL ($this:.additionalText$delegate..>, t:F11T of .additionalText$delegate..qux11) returnType:F11T of .additionalText$delegate..qux11 TYPE_PARAMETER name:F11T index:0 variance: superTypes:[kotlin.Any?] reified:false $this: VALUE_PARAMETER name: type:.additionalText$delegate..> @@ -214,34 +214,34 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun qux11 (t: F11T of .additionalText$delegate..qux11): F11T of .additionalText$delegate..qux11 declared in .additionalText$delegate.' GET_VAR 't: F11T of .additionalText$delegate..qux11 declared in .additionalText$delegate..qux11' type=F11T of .additionalText$delegate..qux11 origin=null - FUN name:qux12 visibility:public modality:FINAL ($this:.additionalText$delegate..>, t:F12T of .additionalText$delegate..qux12) returnType:T of . - TYPE_PARAMETER name:F12T index:0 variance: superTypes:[.IR.>] reified:false + FUN name:qux12 visibility:public modality:FINAL ($this:.additionalText$delegate..>, t:F12T of .additionalText$delegate..qux12) returnType:kotlin.Any? + TYPE_PARAMETER name:F12T index:0 variance: superTypes:[.IR] reified:false $this: VALUE_PARAMETER name: type:.additionalText$delegate..> VALUE_PARAMETER name:t index:0 type:F12T of .additionalText$delegate..qux12 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun qux12 (t: F12T of .additionalText$delegate..qux12): T of . declared in .additionalText$delegate.' - CALL 'public abstract fun foo (): R of .IR declared in .IR' type=T of . origin=null + RETURN type=kotlin.Nothing from='public final fun qux12 (t: F12T of .additionalText$delegate..qux12): kotlin.Any? declared in .additionalText$delegate.' + CALL 'public abstract fun foo (): R of .IR declared in .IR' type=kotlin.Any? origin=null $this: GET_VAR 't: F12T of .additionalText$delegate..qux12 declared in .additionalText$delegate..qux12' type=F12T of .additionalText$delegate..qux12 origin=null PROPERTY name:deepO visibility:private modality:FINAL [delegated,val] - FIELD PROPERTY_DELEGATE name:deepO$delegate type:.additionalText$delegate..deepO$delegate..> visibility:private [final] + FIELD PROPERTY_DELEGATE name:deepO$delegate type:.additionalText$delegate..deepO$delegate. visibility:private [final] EXPRESSION_BODY BLOCK type=.additionalText$delegate..deepO$delegate..> origin=OBJECT_LITERAL - CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value., .CR.>>, T of .>] + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value.CR>, kotlin.Any?>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.additionalText$delegate..deepO$delegate..> - CONSTRUCTOR visibility:public <> () returnType:.additionalText$delegate..deepO$delegate..> [primary] + CONSTRUCTOR visibility:public <> () returnType:.additionalText$delegate..deepO$delegate. [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value., .CR.>>, T of .>]' - FUN name:getValue visibility:public modality:OPEN <> ($this:.additionalText$delegate..deepO$delegate..>, t:.Value., .CR.>>, p:kotlin.reflect.KProperty<*>) returnType:T of . [operator] + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value.CR>, kotlin.Any?>]' + FUN name:getValue visibility:public modality:OPEN <> ($this:.additionalText$delegate..deepO$delegate..>, t:.Value.CR>, p:kotlin.reflect.KProperty<*>) returnType:kotlin.Any? [operator] overridden: public abstract fun getValue (t: T1 of .IDelegate1, p: kotlin.reflect.KProperty<*>): R1 of .IDelegate1 declared in .IDelegate1 $this: VALUE_PARAMETER name: type:.additionalText$delegate..deepO$delegate..> - VALUE_PARAMETER name:t index:0 type:.Value., .CR.>> + VALUE_PARAMETER name:t index:0 type:.Value.CR> VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> BLOCK_BODY - RETURN type=kotlin.Nothing from='public open fun getValue (t: .Value., .CR.>>, p: kotlin.reflect.KProperty<*>): T of . declared in .additionalText$delegate..deepO$delegate.' - CALL 'public final fun (): T of .Value declared in .Value' type=T of . origin=GET_PROPERTY - $this: GET_VAR 't: .Value., .CR.>> declared in .additionalText$delegate..deepO$delegate..getValue' type=.Value., .CR.>> origin=null + RETURN type=kotlin.Nothing from='public open fun getValue (t: .Value.CR>, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .additionalText$delegate..deepO$delegate.' + CALL 'public final fun (): T of .Value declared in .Value' type=kotlin.Any? origin=GET_PROPERTY + $this: GET_VAR 't: .Value.CR> declared in .additionalText$delegate..deepO$delegate..getValue' type=.Value.CR> origin=null FUN name:qux21 visibility:public modality:FINAL ($this:.additionalText$delegate..deepO$delegate..>, t:F21T of .additionalText$delegate..deepO$delegate..qux21) returnType:F21T of .additionalText$delegate..deepO$delegate..qux21 TYPE_PARAMETER name:F21T index:0 variance: superTypes:[kotlin.Any?] reified:false $this: VALUE_PARAMETER name: type:.additionalText$delegate..deepO$delegate..> @@ -249,13 +249,13 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun qux21 (t: F21T of .additionalText$delegate..deepO$delegate..qux21): F21T of .additionalText$delegate..deepO$delegate..qux21 declared in .additionalText$delegate..deepO$delegate.' GET_VAR 't: F21T of .additionalText$delegate..deepO$delegate..qux21 declared in .additionalText$delegate..deepO$delegate..qux21' type=F21T of .additionalText$delegate..deepO$delegate..qux21 origin=null - FUN name:qux22 visibility:public modality:FINAL ($this:.additionalText$delegate..deepO$delegate..>, t:F22T of .additionalText$delegate..deepO$delegate..qux22) returnType:T of . - TYPE_PARAMETER name:F22T index:0 variance: superTypes:[.IR.>] reified:false + FUN name:qux22 visibility:public modality:FINAL ($this:.additionalText$delegate..deepO$delegate..>, t:F22T of .additionalText$delegate..deepO$delegate..qux22) returnType:kotlin.Any? + TYPE_PARAMETER name:F22T index:0 variance: superTypes:[.IR] reified:false $this: VALUE_PARAMETER name: type:.additionalText$delegate..deepO$delegate..> VALUE_PARAMETER name:t index:0 type:F22T of .additionalText$delegate..deepO$delegate..qux22 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun qux22 (t: F22T of .additionalText$delegate..deepO$delegate..qux22): T of . declared in .additionalText$delegate..deepO$delegate.' - CALL 'public abstract fun foo (): R of .IR declared in .IR' type=T of . origin=null + RETURN type=kotlin.Nothing from='public final fun qux22 (t: F22T of .additionalText$delegate..deepO$delegate..qux22): kotlin.Any? declared in .additionalText$delegate..deepO$delegate.' + CALL 'public abstract fun foo (): R of .IR declared in .IR' type=kotlin.Any? origin=null $this: GET_VAR 't: F22T of .additionalText$delegate..deepO$delegate..qux22 declared in .additionalText$delegate..deepO$delegate..qux22' type=F22T of .additionalText$delegate..deepO$delegate..qux22 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -271,38 +271,39 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt public open fun toString (): kotlin.String declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'public constructor () declared in .additionalText$delegate..deepO$delegate.' type=.additionalText$delegate..deepO$delegate..> origin=OBJECT_LITERAL - FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.additionalText$delegate..>, $receiver:.Value., .CR.>>) returnType:T of . + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.additionalText$delegate..>, $receiver:.Value.CR>) returnType:kotlin.Any? correspondingProperty: PROPERTY name:deepO visibility:private modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.additionalText$delegate..> - $receiver: VALUE_PARAMETER name: type:.Value., .CR.>> + $receiver: VALUE_PARAMETER name: type:.Value.CR> BLOCK_BODY - RETURN type=kotlin.Nothing from='private final fun (): T of . declared in .additionalText$delegate.' - CALL 'public open fun getValue (t: .Value., .CR.>>, p: kotlin.reflect.KProperty<*>): T of . declared in .additionalText$delegate..deepO$delegate.' type=T of . origin=null - $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:deepO$delegate type:.additionalText$delegate..deepO$delegate..> visibility:private [final]' type=.additionalText$delegate..deepO$delegate..> origin=null - receiver: GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null - t: GET_VAR ': .Value., .CR.>> declared in .additionalText$delegate..' type=.Value., .CR.>> origin=null - p: PROPERTY_REFERENCE 'private final deepO: T of .' field=null getter='private final fun (): T of . declared in .additionalText$delegate.' setter=null type=kotlin.reflect.KProperty2<.Value., .CR.>>, *, T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE + RETURN type=kotlin.Nothing from='private final fun (): kotlin.Any? declared in .additionalText$delegate.' + CALL 'public open fun getValue (t: .Value.CR>, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .additionalText$delegate..deepO$delegate.' type=kotlin.Any? origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:deepO$delegate type:.additionalText$delegate..deepO$delegate. visibility:private [final]' type=.additionalText$delegate..deepO$delegate. origin=null + receiver: TYPE_OP type=.additionalText$delegate. origin=IMPLICIT_CAST typeOperand=.additionalText$delegate. + GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null + t: GET_VAR ': .Value.CR> declared in .additionalText$delegate..' type=.Value.CR> origin=null + p: PROPERTY_REFERENCE 'private final deepO: kotlin.Any?' field=null getter='private final fun (): kotlin.Any? declared in .additionalText$delegate.' setter=null type=kotlin.reflect.KProperty2<.Value.CR>, *, kotlin.Any?> origin=PROPERTY_REFERENCE_FOR_DELEGATE PROPERTY name:deepK visibility:private modality:FINAL [delegated,val] - FIELD PROPERTY_DELEGATE name:deepK$delegate type:.additionalText$delegate..deepK$delegate..> visibility:private [final] + FIELD PROPERTY_DELEGATE name:deepK$delegate type:.additionalText$delegate..deepK$delegate. visibility:private [final] EXPRESSION_BODY BLOCK type=.additionalText$delegate..deepK$delegate..> origin=OBJECT_LITERAL - CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value., .CR.>>, T of .>] + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value.CR>, kotlin.Any?>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.additionalText$delegate..deepK$delegate..> - CONSTRUCTOR visibility:public <> () returnType:.additionalText$delegate..deepK$delegate..> [primary] + CONSTRUCTOR visibility:public <> () returnType:.additionalText$delegate..deepK$delegate. [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value., .CR.>>, T of .>]' - FUN name:getValue visibility:public modality:OPEN <> ($this:.additionalText$delegate..deepK$delegate..>, t:.Value., .CR.>>, p:kotlin.reflect.KProperty<*>) returnType:T of . [operator] + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.IDelegate1<.Value.CR>, kotlin.Any?>]' + FUN name:getValue visibility:public modality:OPEN <> ($this:.additionalText$delegate..deepK$delegate..>, t:.Value.CR>, p:kotlin.reflect.KProperty<*>) returnType:kotlin.Any? [operator] overridden: public abstract fun getValue (t: T1 of .IDelegate1, p: kotlin.reflect.KProperty<*>): R1 of .IDelegate1 declared in .IDelegate1 $this: VALUE_PARAMETER name: type:.additionalText$delegate..deepK$delegate..> - VALUE_PARAMETER name:t index:0 type:.Value., .CR.>> + VALUE_PARAMETER name:t index:0 type:.Value.CR> VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> BLOCK_BODY - RETURN type=kotlin.Nothing from='public open fun getValue (t: .Value., .CR.>>, p: kotlin.reflect.KProperty<*>): T of . declared in .additionalText$delegate..deepK$delegate.' - CALL 'public open fun foo (): R of .CR declared in .CR' type=T of . origin=null - $this: CALL 'public final fun (): IT of .Value declared in .Value' type=.CR.> origin=GET_PROPERTY - $this: GET_VAR 't: .Value., .CR.>> declared in .additionalText$delegate..deepK$delegate..getValue' type=.Value., .CR.>> origin=null + RETURN type=kotlin.Nothing from='public open fun getValue (t: .Value.CR>, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .additionalText$delegate..deepK$delegate.' + CALL 'public open fun foo (): R of .CR declared in .CR' type=kotlin.Any? origin=null + $this: CALL 'public final fun (): IT of .Value declared in .Value' type=.CR origin=GET_PROPERTY + $this: GET_VAR 't: .Value.CR> declared in .additionalText$delegate..deepK$delegate..getValue' type=.Value.CR> 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 declared in .IDelegate1 @@ -317,34 +318,37 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt public open fun toString (): kotlin.String declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'public constructor () declared in .additionalText$delegate..deepK$delegate.' type=.additionalText$delegate..deepK$delegate..> origin=OBJECT_LITERAL - FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.additionalText$delegate..>, $receiver:.Value., .CR.>>) returnType:T of . + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.additionalText$delegate..>, $receiver:.Value.CR>) returnType:kotlin.Any? correspondingProperty: PROPERTY name:deepK visibility:private modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.additionalText$delegate..> - $receiver: VALUE_PARAMETER name: type:.Value., .CR.>> + $receiver: VALUE_PARAMETER name: type:.Value.CR> BLOCK_BODY - RETURN type=kotlin.Nothing from='private final fun (): T of . declared in .additionalText$delegate.' - CALL 'public open fun getValue (t: .Value., .CR.>>, p: kotlin.reflect.KProperty<*>): T of . declared in .additionalText$delegate..deepK$delegate.' type=T of . origin=null - $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:deepK$delegate type:.additionalText$delegate..deepK$delegate..> visibility:private [final]' type=.additionalText$delegate..deepK$delegate..> origin=null - receiver: GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null - t: GET_VAR ': .Value., .CR.>> declared in .additionalText$delegate..' type=.Value., .CR.>> origin=null - p: PROPERTY_REFERENCE 'private final deepK: T of .' field=null getter='private final fun (): T of . declared in .additionalText$delegate.' setter=null type=kotlin.reflect.KProperty2<.Value., .CR.>>, *, T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE - FUN name:getValue visibility:public modality:OPEN <> ($this:.additionalText$delegate..>, t:.Value., .CR.>>, p:kotlin.reflect.KProperty<*>) returnType:.P., T of .> [operator] + RETURN type=kotlin.Nothing from='private final fun (): kotlin.Any? declared in .additionalText$delegate.' + CALL 'public open fun getValue (t: .Value.CR>, p: kotlin.reflect.KProperty<*>): kotlin.Any? declared in .additionalText$delegate..deepK$delegate.' type=kotlin.Any? origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:deepK$delegate type:.additionalText$delegate..deepK$delegate. visibility:private [final]' type=.additionalText$delegate..deepK$delegate. origin=null + receiver: TYPE_OP type=.additionalText$delegate. origin=IMPLICIT_CAST typeOperand=.additionalText$delegate. + GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null + t: GET_VAR ': .Value.CR> declared in .additionalText$delegate..' type=.Value.CR> origin=null + p: PROPERTY_REFERENCE 'private final deepK: kotlin.Any?' field=null getter='private final fun (): kotlin.Any? declared in .additionalText$delegate.' setter=null type=kotlin.reflect.KProperty2<.Value.CR>, *, kotlin.Any?> origin=PROPERTY_REFERENCE_FOR_DELEGATE + FUN name:getValue visibility:public modality:OPEN <> ($this:.additionalText$delegate..>, t:.Value.CR>, p:kotlin.reflect.KProperty<*>) returnType:.P [operator] overridden: public abstract fun getValue (t: T1 of .IDelegate1, p: kotlin.reflect.KProperty<*>): R1 of .IDelegate1 declared in .IDelegate1 $this: VALUE_PARAMETER name: type:.additionalText$delegate..> - VALUE_PARAMETER name:t index:0 type:.Value., .CR.>> + VALUE_PARAMETER name:t index:0 type:.Value.CR> VALUE_PARAMETER name:p index:1 type:kotlin.reflect.KProperty<*> BLOCK_BODY - RETURN type=kotlin.Nothing from='public open fun getValue (t: .Value., .CR.>>, p: kotlin.reflect.KProperty<*>): .P., T of .> declared in .additionalText$delegate.' - CONSTRUCTOR_CALL 'public constructor (p1: P1 of .P, p2: P2 of .P) declared in .P' type=.P., T of .> origin=null - : T of . - : T of . - p1: CALL 'private final fun (): T of . declared in .additionalText$delegate.' type=T of . origin=GET_PROPERTY - $this: GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..getValue' type=.additionalText$delegate..> origin=null - $receiver: GET_VAR 't: .Value., .CR.>> declared in .additionalText$delegate..getValue' type=.Value., .CR.>> origin=null - p2: CALL 'private final fun (): T of . declared in .additionalText$delegate.' type=T of . origin=GET_PROPERTY - $this: GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..getValue' type=.additionalText$delegate..> origin=null - $receiver: GET_VAR 't: .Value., .CR.>> declared in .additionalText$delegate..getValue' type=.Value., .CR.>> origin=null + RETURN type=kotlin.Nothing from='public open fun getValue (t: .Value.CR>, p: kotlin.reflect.KProperty<*>): .P declared in .additionalText$delegate.' + CONSTRUCTOR_CALL 'public constructor (p1: P1 of .P, p2: P2 of .P) declared in .P' type=.P origin=null + : kotlin.Any? + : kotlin.Any? + p1: CALL 'private final fun (): kotlin.Any? declared in .additionalText$delegate.' type=kotlin.Any? origin=GET_PROPERTY + $this: TYPE_OP type=.additionalText$delegate. origin=IMPLICIT_CAST typeOperand=.additionalText$delegate. + GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..getValue' type=.additionalText$delegate..> origin=null + $receiver: GET_VAR 't: .Value.CR> declared in .additionalText$delegate..getValue' type=.Value.CR> origin=null + p2: CALL 'private final fun (): kotlin.Any? declared in .additionalText$delegate.' type=kotlin.Any? origin=GET_PROPERTY + $this: TYPE_OP type=.additionalText$delegate. origin=IMPLICIT_CAST typeOperand=.additionalText$delegate. + GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..getValue' type=.additionalText$delegate..> origin=null + $receiver: GET_VAR 't: .Value.CR> declared in .additionalText$delegate..getValue' type=.Value.CR> 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 declared in .IDelegate1 @@ -365,7 +369,7 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt $receiver: VALUE_PARAMETER name: type:.Value., .CR.>> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): .P., T of .> declared in ' - CALL 'public open fun getValue (t: .Value., .CR.>>, p: kotlin.reflect.KProperty<*>): .P., T of .> declared in .additionalText$delegate.' type=.P., T of .> origin=null + CALL 'public open fun getValue (t: .Value.CR>, p: kotlin.reflect.KProperty<*>): .P declared in .additionalText$delegate.' type=.P., T of .> origin=null $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:additionalText$delegate type:.additionalText$delegate..> visibility:private [final,static]' type=.additionalText$delegate..> origin=null t: GET_VAR ': .Value., .CR.>> declared in .' type=.Value., .CR.>> origin=null p: PROPERTY_REFERENCE 'public final additionalText: .P., T of .>' field=null getter='public final fun (): .P., T of .> declared in ' setter=null type=kotlin.reflect.KProperty1<.Value., .CR.>>, .P., T of .>> origin=PROPERTY_REFERENCE_FOR_DELEGATE diff --git a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.kt.txt b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.kt.txt index 09e8034d2cf..d60911f1e11 100644 --- a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.kt.txt +++ b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.kt.txt @@ -67,7 +67,7 @@ class P { val Value>.additionalText: P /* by */ field = { // BLOCK - local class : IDelegate1>, P> { + local class : IDelegate1>, P> { constructor() /* primary */ { super/*Any*/() /* () */ @@ -78,20 +78,20 @@ val Value>.additionalText: P /* by */ return t } - fun > qux12(t: F12T): T { + fun > qux12(t: F12T): Any? { return t.foo() } - private val Value>.deepO: T /* by */ + private val Value>.deepO: Any? /* by */ field = { // BLOCK - local class : IDelegate1>, T> { + local class : IDelegate1>, Any?> { constructor() /* primary */ { super/*Any*/() /* () */ } - override operator fun getValue(t: Value>, p: KProperty<*>): T { + override operator fun getValue(t: Value>, p: KProperty<*>): Any? { return t.() } @@ -99,7 +99,7 @@ val Value>.additionalText: P /* by */ return t } - fun > qux22(t: F22T): T { + fun > qux22(t: F22T): Any? { return t.foo() } @@ -107,20 +107,20 @@ val Value>.additionalText: P /* by */ () } - private get(): T { - return .#deepO$delegate.getValue(t = , p = ::deepO) + private get(): Any? { + return /*as */.#deepO$delegate.getValue(t = , p = ::deepO) } - private val Value>.deepK: T /* by */ + private val Value>.deepK: Any? /* by */ field = { // BLOCK - local class : IDelegate1>, T> { + local class : IDelegate1>, Any?> { constructor() /* primary */ { super/*Any*/() /* () */ } - override operator fun getValue(t: Value>, p: KProperty<*>): T { + override operator fun getValue(t: Value>, p: KProperty<*>): Any? { return t.().foo() } @@ -128,12 +128,12 @@ val Value>.additionalText: P /* by */ () } - private get(): T { - return .#deepK$delegate.getValue(t = , p = ::deepK) + private get(): Any? { + return /*as */.#deepK$delegate.getValue(t = , p = ::deepK) } - override operator fun getValue(t: Value>, p: KProperty<*>): P { - return P(p1 = (, t).(), p2 = (, t).()) + override operator fun getValue(t: Value>, p: KProperty<*>): P { + return P(p1 = ( /*as */, t).(), p2 = ( /*as */, t).()) } } @@ -143,3 +143,4 @@ val Value>.additionalText: P /* by */ get(): P { return #additionalText$delegate.getValue(t = , p = ::additionalText/*()*/) } + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java index b35b12a37cd..d0761ffbb6e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java @@ -16107,6 +16107,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 6c86bb69e73..ce3a6af91f1 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -16107,6 +16107,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 97698f1777c..741f24bf2f2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -16107,6 +16107,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @Test + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @Test @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index b996aa064dd..8277cf0999b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13265,6 +13265,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt"); } + @TestMetadata("typeParameterInDelegatedProperty.kt") + public void testTypeParameterInDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/typeParameterInDelegatedProperty.kt"); + } + @TestMetadata("useKPropertyLater.kt") public void testUseKPropertyLater() throws Exception { runTest("compiler/testData/codegen/box/delegatedProperty/useKPropertyLater.kt");