From 65b2cee913ecfc42b04405d2da2d2a357caa3d4b Mon Sep 17 00:00:00 2001 From: Pavel Mikhailovskii Date: Fri, 3 Jun 2022 16:54:12 +0200 Subject: [PATCH] KT-23397 Optimize out field for property delegate when it's safe (JVM) --- .../FirBlackBoxCodegenTestGenerated.java | 208 ++++++++++++++++++ .../jetbrains/kotlin/backend/jvm/JvmLower.kt | 1 + .../PropertyReferenceDelegationLowering.kt | 21 +- .../SingletonOrConstantDelegationLowering.kt | 104 +++++++++ .../org/jetbrains/kotlin/ir/util/IrUtils.kt | 20 ++ .../delegateToConst/delegateToConst.kt | 8 + .../delegateToConst/delegateToConst.txt | 10 + .../delegateToConstProperty.kt | 10 + .../delegateToConstProperty.txt | 11 + .../delegateToConstProperty_ir.txt | 11 + .../delegateToConst/delegateToConst_ir.txt | 10 + .../delegateToConst/delegateToNull.kt | 8 + .../delegateToConst/delegateToNull.txt | 10 + .../delegateToConst/delegateToNull_ir.txt | 10 + .../delegateToFinalProperty/chain.kt | 26 +++ .../delegateToFinalProperty/chain.txt | 44 ++++ .../delegateToFinalProperty/chain_ir.txt | 44 ++++ .../delegateToFinalInstanceProperty.kt | 14 ++ .../delegateToFinalInstanceProperty.txt | 21 ++ .../delegateToFinalInstanceProperty_ir.txt | 21 ++ .../delegateToFinalObjectProperty.kt | 12 + .../delegateToFinalObjectProperty.txt | 20 ++ .../delegateToFinalObjectProperty_ir.txt | 20 ++ .../delegateToFinalProperty.kt | 10 + .../delegateToFinalProperty.txt | 12 + .../delegateToFinalProperty_ir.txt | 12 + .../finalPropertyInAnotherFile.kt | 12 + .../finalPropertyInAnotherFile.txt | 12 + .../finalPropertyInAnotherFile_ir.txt | 12 + ...initializeContainerOfTopLevelProperties.kt | 18 ++ ...berExtensionPropertyAndImportFromObject.kt | 18 ++ ...erExtensionPropertyAndImportFromObject.txt | 36 +++ ...xtensionPropertyAndImportFromObject_ir.txt | 37 ++++ ...ensionPropertyAndLocalDelegatedProperty.kt | 17 ++ ...nsionPropertyAndLocalDelegatedProperty.txt | 34 +++ ...onPropertyAndLocalDelegatedProperty_ir.txt | 36 +++ .../delegateToFinalProperty/multimodule.kt | 14 ++ .../delegateToFinalProperty/multimodule.txt | 19 ++ .../delegateToSingleton/delegateToEnum.kt | 13 ++ .../delegateToSingleton/delegateToEnum.txt | 22 ++ .../delegateToEnumInAClass.kt | 17 ++ .../delegateToEnumInAClass.txt | 31 +++ .../delegateToEnumInAClass_ir.txt | 32 +++ .../delegateToSingleton/delegateToEnum_ir.txt | 23 ++ .../delegateToSingleton.kt | 25 +++ .../delegateToSingleton.txt | 28 +++ .../delegateToSingleton_ir.txt | 28 +++ .../noInitializationOfOuterClass.kt | 15 ++ .../noInitializationOfOuterClass.txt | 28 +++ .../noInitializationOfOuterClass_ir.txt | 28 +++ .../delegateToSingleton/withSideEffects.kt | 23 ++ .../delegateToSingleton/withSideEffects.txt | 27 +++ .../withSideEffectsFromFileClass.kt | 19 ++ .../withSideEffectsFromFileClass.txt | 21 ++ .../withSideEffectsFromFileClass_ir.txt | 21 ++ .../withSideEffectsToEnum.kt | 22 ++ .../withSideEffectsToEnum.txt | 34 +++ .../withSideEffectsToEnum_ir.txt | 35 +++ .../withSideEffects_ir.txt | 28 +++ .../delegateToThis/delegateToOuterThis.kt | 13 ++ .../delegateToThis/delegateToOuterThis.txt | 25 +++ .../delegateToThis/delegateToOuterThis_ir.txt | 25 +++ .../delegateToThis/delegateToThis.kt | 11 + .../delegateToThis/delegateToThis.txt | 16 ++ .../delegateToThisByExtension.kt | 13 ++ .../delegateToThisByExtension.txt | 19 ++ .../delegateToThisByExtension_ir.txt | 19 ++ .../delegateToThis/delegateToThis_ir.txt | 16 ++ .../box/jvmName/propertyAccessorsUseSite.kt | 2 +- .../getDelegate/method/delegateToConst.kt | 17 ++ .../method/delegateToConstProperty.kt | 18 ++ .../getDelegate/method/delegateToEnum.kt | 18 ++ .../method/delegateToFinalObjectProperty.kt | 21 ++ .../method/delegateToFinalProperty.kt | 18 ++ .../getDelegate/method/delegateToSingleton.kt | 27 +++ .../codegen/BlackBoxCodegenTestGenerated.java | 208 ++++++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 208 ++++++++++++++++++ .../LightAnalysisModeTestGenerated.java | 192 ++++++++++++++++ .../js/test/JsCodegenBoxTestGenerated.java | 166 ++++++++++++++ .../test/ir/IrJsCodegenBoxTestGenerated.java | 166 ++++++++++++++ .../IrCodegenBoxWasmTestGenerated.java | 157 +++++++++++++ .../tools/kotlinp/testData/Properties.txt | 2 +- .../NativeCodegenBoxTestGenerated.java | 174 +++++++++++++++ 83 files changed, 3015 insertions(+), 19 deletions(-) create mode 100644 compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonOrConstantDelegationLowering.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension_ir.txt create mode 100644 compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis_ir.txt create mode 100644 compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt create mode 100644 compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt create mode 100644 compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt create mode 100644 compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt create mode 100644 compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt create mode 100644 compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index c7b63639b41..f4b5524e2d1 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -14597,6 +14597,178 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToConst { + @Test + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToFinalProperty { + @Test + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @Test + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @Test + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + + @Test + @TestMetadata("multimodule.kt") + public void testMultimodule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToSingleton { + @Test + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @Test + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @Test + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @Test + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @Test + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToThis { + @Test + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @Test + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @Test + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT") @@ -42815,6 +42987,42 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testDelegateToAnother() throws Exception { runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt"); } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt"); + } } } diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt index 242e9e234f2..0aad442091e 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt @@ -290,6 +290,7 @@ private val jvmFilePhases = listOf( functionReferencePhase, suspendLambdaPhase, propertyReferenceDelegationPhase, + singletonOrConstantDelegationPhase, propertyReferencePhase, arrayConstructorPhase, constPhase1, diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt index 617b8ca166e..03ebb2bf2a2 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt @@ -105,19 +105,6 @@ private class PropertyReferenceDelegationTransformer(val context: JvmBackendCont correspondingPropertySymbol?.let { it.owner.getter == this && it.owner.setter == null } == true && modality == Modality.FINAL - private fun IrExpression.inline(oldReceiver: IrValueParameter?, newReceiver: IrValueParameter?): IrExpression = when (this) { - is IrGetField -> - IrGetFieldImpl(startOffset, endOffset, symbol, type, receiver?.inline(oldReceiver, newReceiver), origin, superQualifierSymbol) - is IrGetValue -> - IrGetValueImpl(startOffset, endOffset, type, newReceiver?.symbol.takeIf { symbol == oldReceiver?.symbol } ?: symbol, origin) - is IrCall -> - IrCallImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, valueArgumentsCount, origin, superQualifierSymbol).apply { - dispatchReceiver = this@inline.dispatchReceiver?.inline(oldReceiver, newReceiver) - extensionReceiver = this@inline.extensionReceiver?.inline(oldReceiver, newReceiver) - } - else -> shallowCopy() - } - override fun visitClass(declaration: IrClass): IrStatement { declaration.transformChildren(this, null) declaration.transformDeclarationsFlat { @@ -150,14 +137,14 @@ private class PropertyReferenceDelegationTransformer(val context: JvmBackendCont } } val originalThis = parentAsClass.thisReceiver - getter?.apply { body = accessorBody(delegate, backingField ?: receiver?.inline(originalThis, dispatchReceiverParameter)) } - setter?.apply { body = accessorBody(delegate, backingField ?: receiver?.inline(originalThis, dispatchReceiverParameter)) } + getter?.apply { body = accessorBody(delegate, backingField ?: receiver?.remapReceiver(originalThis, dispatchReceiverParameter)) } + setter?.apply { body = accessorBody(delegate, backingField ?: receiver?.remapReceiver(originalThis, dispatchReceiverParameter)) } // The `$delegate` method is generated as instance method here, see MakePropertyDelegateMethodsStaticLowering. val delegateMethod = context.createSyntheticMethodForPropertyDelegate(this).apply { body = context.createJvmIrBuilder(symbol).run { val boundReceiver = backingField?.let { irGetField(dispatchReceiverParameter?.let(::irGet), it) } - ?: receiver?.inline(originalThis, dispatchReceiverParameter) + ?: receiver?.remapReceiver(originalThis, dispatchReceiverParameter) irExprBody(with(delegate) { val origin = PropertyReferenceLowering.REFLECTED_PROPERTY_REFERENCE IrPropertyReferenceImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, field, getter, setter, origin) @@ -179,7 +166,7 @@ private class PropertyReferenceDelegationTransformer(val context: JvmBackendCont symbol, parentAsClass.isFacadeClass ).apply { - body = context.irFactory.createBlockBody(startOffset, endOffset, listOf(it.inline(null, null))) + body = context.irFactory.createBlockBody(startOffset, endOffset, listOf(it.remapReceiver(null, null))) } } return listOfNotNull(this, delegateMethod, receiverBlock) diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonOrConstantDelegationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonOrConstantDelegationLowering.kt new file mode 100644 index 00000000000..907f19883a3 --- /dev/null +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonOrConstantDelegationLowering.kt @@ -0,0 +1,104 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.jvm.lower + +import org.jetbrains.kotlin.backend.common.FileLoweringPass +import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase +import org.jetbrains.kotlin.backend.jvm.JvmBackendContext +import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder +import org.jetbrains.kotlin.backend.jvm.lower.JvmPropertiesLowering.Companion.createSyntheticMethodForPropertyDelegate +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.ir.builders.irExprBody +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.ir.visitors.IrElementTransformer +import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.util.OperatorNameConventions + +internal val singletonOrConstantDelegationPhase = makeIrFilePhase( + ::SingletonOrConstantDelegationLowering, + name = "SingletonOrConstantDelegation", + description = "Optimize `val x by ConstOrSingleton`: there is no need to store the value in a field" +) + +private class SingletonOrConstantDelegationLowering(val context: JvmBackendContext) : FileLoweringPass { + override fun lower(irFile: IrFile) { + if (!context.state.generateOptimizedCallableReferenceSuperClasses) return + irFile.transform(SingletonOrConstantDelegationTransformer(context), null) + } +} + +private class SingletonOrConstantDelegationTransformer(val context: JvmBackendContext) : IrElementTransformerVoid() { + override fun visitClass(declaration: IrClass): IrClass { + declaration.transformChildren(this, null) + declaration.transformDeclarationsFlat { + (it as? IrProperty)?.transform() + } + return declaration + } + + private fun IrProperty.transform(): List? { + if (!isDelegated || isFakeOverride || backingField == null) return null + val delegate = backingField?.initializer?.expression?.takeIf { it.isInlineable() } ?: return null + val originalThis = parentAsClass.thisReceiver + val receiverMapper = object : IrElementTransformer> { + override fun visitCall(expression: IrCall, data: Pair): IrExpression { + val (name, newReceiver) = data + if (expression.symbol.owner.name == name) { + if ((expression.dispatchReceiver as? IrGetField)?.symbol == backingField?.symbol) { + expression.dispatchReceiver = newReceiver + } else if ((expression.extensionReceiver as? IrGetField)?.symbol == backingField?.symbol) { + expression.extensionReceiver = newReceiver + } + } + return expression + } + } + + getter?.transform(receiverMapper,OperatorNameConventions.GET_VALUE to delegate.remapReceiver(originalThis, getter?.dispatchReceiverParameter)) + setter?.transform(receiverMapper,OperatorNameConventions.SET_VALUE to delegate.remapReceiver(originalThis, setter?.dispatchReceiverParameter)) + + backingField = null + + val initializerBlock = if (delegate !is IrConst<*> && delegate !is IrGetValue) + context.irFactory.createAnonymousInitializer( + delegate.startOffset, + delegate.endOffset, + IrDeclarationOrigin.DEFINED, + IrAnonymousInitializerSymbolImpl(parentAsClass.symbol), + parentAsClass.isFileClass + ).apply { + body = context.irFactory.createBlockBody(delegate.startOffset, delegate.endOffset, listOf(delegate.remapReceiver(null, null))) + } + else null + + val delegateMethod = context.createSyntheticMethodForPropertyDelegate(this).apply { + body = context.createJvmIrBuilder(symbol).run { irExprBody(delegate.remapReceiver(originalThis, dispatchReceiverParameter)) } + } + + return listOfNotNull(this, initializerBlock, delegateMethod) + } + + private fun IrExpression.isInlineable(): Boolean = + when (this) { + is IrConst<*>, is IrGetSingletonValue -> true + is IrCall -> + dispatchReceiver?.isInlineable() != false + && extensionReceiver?.isInlineable() != false + && valueArgumentsCount == 0 + && symbol.owner.run { + modality == Modality.FINAL + && origin == IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR + && ((body?.statements?.singleOrNull() as? IrReturn)?.value as? IrGetField)?.symbol?.owner?.isFinal == true + } + is IrGetValue -> + symbol.owner.origin == IrDeclarationOrigin.INSTANCE_RECEIVER + else -> false + } +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt index c33c5d0fea8..8517a2150a9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt @@ -600,6 +600,13 @@ fun IrExpression.shallowCopy(): IrExpression = fun IrExpression.shallowCopyOrNull(): IrExpression? = when (this) { is IrConst<*> -> shallowCopy() + is IrGetEnumValue -> + IrGetEnumValueImpl( + startOffset, + endOffset, + type, + symbol + ) is IrGetObjectValue -> IrGetObjectValueImpl( startOffset, @@ -633,6 +640,19 @@ internal fun IrConst.shallowCopy() = IrConstImpl( value ) +fun IrExpression.remapReceiver(oldReceiver: IrValueParameter?, newReceiver: IrValueParameter?): IrExpression = when (this) { + is IrGetField -> + IrGetFieldImpl(startOffset, endOffset, symbol, type, receiver?.remapReceiver(oldReceiver, newReceiver), origin, superQualifierSymbol) + is IrGetValue -> + IrGetValueImpl(startOffset, endOffset, type, newReceiver?.symbol.takeIf { symbol == oldReceiver?.symbol } ?: symbol, origin) + is IrCall -> + IrCallImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, valueArgumentsCount, origin, superQualifierSymbol).also { + it.dispatchReceiver = dispatchReceiver?.remapReceiver(oldReceiver, newReceiver) + it.extensionReceiver = extensionReceiver?.remapReceiver(oldReceiver, newReceiver) + } + else -> shallowCopy() +} + val IrDeclarationParent.isFacadeClass: Boolean get() = this is IrClass && (origin == IrDeclarationOrigin.JVM_MULTIFILE_CLASS || diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt new file mode 100644 index 00000000000..7789b469111 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt @@ -0,0 +1,8 @@ +// CHECK_BYTECODE_LISTING + +operator fun Any?.getValue(thisRef: Any?, property: Any?) = + if (this == 1 && thisRef == null) "OK" else "Failed" + +val s: String by 1 + +fun box() = s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.txt new file mode 100644 index 00000000000..0166fe3fd70 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.txt @@ -0,0 +1,10 @@ +@kotlin.Metadata +public final class DelegateToConstKt { + // source: 'delegateToConst.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static field s$delegate: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt new file mode 100644 index 00000000000..659b14e7208 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt @@ -0,0 +1,10 @@ +// CHECK_BYTECODE_LISTING + +operator fun Any?.getValue(thisRef: Any?, property: Any?) = + if (this == a && thisRef == null) "OK" else "Failed" + +const val a = "TEXT" + +val s: String by a + +fun box(): String = s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.txt new file mode 100644 index 00000000000..f39ae280fdb --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.txt @@ -0,0 +1,11 @@ +@kotlin.Metadata +public final class DelegateToConstPropertyKt { + // source: 'delegateToConstProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + public final static @org.jetbrains.annotations.NotNull field a: java.lang.String + private final static @org.jetbrains.annotations.NotNull field s$delegate: java.lang.String + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty_ir.txt new file mode 100644 index 00000000000..765c54aa36c --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty_ir.txt @@ -0,0 +1,11 @@ +@kotlin.Metadata +public final class DelegateToConstPropertyKt { + // source: 'delegateToConstProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + public final static @org.jetbrains.annotations.NotNull field a: java.lang.String + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst_ir.txt new file mode 100644 index 00000000000..25b411949a6 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst_ir.txt @@ -0,0 +1,10 @@ +@kotlin.Metadata +public final class DelegateToConstKt { + // source: 'delegateToConst.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt new file mode 100644 index 00000000000..91c7e0cea07 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt @@ -0,0 +1,8 @@ +// CHECK_BYTECODE_LISTING + +operator fun Any?.getValue(thisRef: Any?, property: Any?) = + if (this == null && thisRef == null) "OK" else "Failed" + +val s: String by null + +fun box() = s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.txt new file mode 100644 index 00000000000..3568a066a50 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.txt @@ -0,0 +1,10 @@ +@kotlin.Metadata +public final class DelegateToNullKt { + // source: 'delegateToNull.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static @org.jetbrains.annotations.NotNull field s$delegate: java.lang.Void + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull_ir.txt new file mode 100644 index 00000000000..642b58f9fa8 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull_ir.txt @@ -0,0 +1,10 @@ +@kotlin.Metadata +public final class DelegateToNullKt { + // source: 'delegateToNull.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt new file mode 100644 index 00000000000..1ab9f27b889 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt @@ -0,0 +1,26 @@ +// CHECK_BYTECODE_LISTING + +class A { + val b = B() +} + +class B { + val c = C() +} + +class C { + val d = D() +} + +class D { + val e = 1 +} + +val a = A() + +operator fun Int.getValue(thisRef: Any?, property: Any?) = + if (this == 1 && thisRef == null) "OK" else "Failed" + +val x by a.b.c.d.e + +fun box() = x diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.txt new file mode 100644 index 00000000000..afc11ec0d5a --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.txt @@ -0,0 +1,44 @@ +@kotlin.Metadata +public final class A { + // source: 'chain.kt' + private final @org.jetbrains.annotations.NotNull field b: B + public method (): void + public final @org.jetbrains.annotations.NotNull method getB(): B +} + +@kotlin.Metadata +public final class B { + // source: 'chain.kt' + private final @org.jetbrains.annotations.NotNull field c: C + public method (): void + public final @org.jetbrains.annotations.NotNull method getC(): C +} + +@kotlin.Metadata +public final class C { + // source: 'chain.kt' + private final @org.jetbrains.annotations.NotNull field d: D + public method (): void + public final @org.jetbrains.annotations.NotNull method getD(): D +} + +@kotlin.Metadata +public final class ChainKt { + // source: 'chain.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static @org.jetbrains.annotations.NotNull field a: A + private final static field x$delegate: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getA(): A + public final static @org.jetbrains.annotations.NotNull method getValue(p0: int, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getX(): java.lang.String +} + +@kotlin.Metadata +public final class D { + // source: 'chain.kt' + private final field e: int + public method (): void + public final method getE(): int +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain_ir.txt new file mode 100644 index 00000000000..0ac1104b918 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain_ir.txt @@ -0,0 +1,44 @@ +@kotlin.Metadata +public final class A { + // source: 'chain.kt' + private final @org.jetbrains.annotations.NotNull field b: B + public method (): void + public final @org.jetbrains.annotations.NotNull method getB(): B +} + +@kotlin.Metadata +public final class B { + // source: 'chain.kt' + private final @org.jetbrains.annotations.NotNull field c: C + public method (): void + public final @org.jetbrains.annotations.NotNull method getC(): C +} + +@kotlin.Metadata +public final class C { + // source: 'chain.kt' + private final @org.jetbrains.annotations.NotNull field d: D + public method (): void + public final @org.jetbrains.annotations.NotNull method getD(): D +} + +@kotlin.Metadata +public final class ChainKt { + // source: 'chain.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static @org.jetbrains.annotations.NotNull field a: A + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getA(): A + public final static @org.jetbrains.annotations.NotNull method getValue(p0: int, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String + private static method getX$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getX(): java.lang.String +} + +@kotlin.Metadata +public final class D { + // source: 'chain.kt' + private final field e: int + public method (): void + public final method getE(): int +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt new file mode 100644 index 00000000000..007dcea2b4b --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt @@ -0,0 +1,14 @@ +// CHECK_BYTECODE_LISTING + + +class C { + val impl = 123 + val s: String by impl +} + +val c = C() + +operator fun Any?.getValue(thisRef: Any?, property: Any?) = + if (this == 123 && thisRef == c) "OK" else "Failed" + +fun box() = c.s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.txt new file mode 100644 index 00000000000..449bfdc77a7 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.txt @@ -0,0 +1,21 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToFinalInstanceProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final field impl: int + private final field s$delegate: int + static method (): void + public method (): void + public final method getImpl(): int + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToFinalInstancePropertyKt { + // source: 'delegateToFinalInstanceProperty.kt' + private final static @org.jetbrains.annotations.NotNull field c: C + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getC(): C + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty_ir.txt new file mode 100644 index 00000000000..6bc5b6c8b5b --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty_ir.txt @@ -0,0 +1,21 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToFinalInstanceProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final field impl: int + static method (): void + public method (): void + public final method getImpl(): int + private static method getS$delegate(p0: C): java.lang.Object + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToFinalInstancePropertyKt { + // source: 'delegateToFinalInstanceProperty.kt' + private final static @org.jetbrains.annotations.NotNull field c: C + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getC(): C + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt new file mode 100644 index 00000000000..cf37c57989c --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt @@ -0,0 +1,12 @@ +// CHECK_BYTECODE_LISTING + +object O { + val impl = 123 +} + +operator fun Any?.getValue(thisRef: Any?, property: Any?) = + if (this == 123 && thisRef == null) "OK" else "Failed" + +val s: String by O.impl + +fun box() = s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.txt new file mode 100644 index 00000000000..34c2e9a771d --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.txt @@ -0,0 +1,20 @@ +@kotlin.Metadata +public final class DelegateToFinalObjectPropertyKt { + // source: 'delegateToFinalObjectProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static field s$delegate: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'delegateToFinalObjectProperty.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + private final static field impl: int + static method (): void + private method (): void + public final method getImpl(): int +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty_ir.txt new file mode 100644 index 00000000000..a1777ec9151 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty_ir.txt @@ -0,0 +1,20 @@ +@kotlin.Metadata +public final class DelegateToFinalObjectPropertyKt { + // source: 'delegateToFinalObjectProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'delegateToFinalObjectProperty.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + private final static field impl: int + static method (): void + private method (): void + public final method getImpl(): int +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt new file mode 100644 index 00000000000..82998179fae --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt @@ -0,0 +1,10 @@ +// CHECK_BYTECODE_LISTING + +val impl = 123 + +operator fun Any?.getValue(thisRef: Any?, property: Any?) = + if (this == 123 && thisRef == null) "OK" else "Failed" + +val s: String by impl + +fun box() = s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.txt new file mode 100644 index 00000000000..33a5d344529 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.txt @@ -0,0 +1,12 @@ +@kotlin.Metadata +public final class DelegateToFinalPropertyKt { + // source: 'delegateToFinalProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static field impl: int + private final static field s$delegate: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getImpl(): int + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty_ir.txt new file mode 100644 index 00000000000..bcf107cf032 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty_ir.txt @@ -0,0 +1,12 @@ +@kotlin.Metadata +public final class DelegateToFinalPropertyKt { + // source: 'delegateToFinalProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static field impl: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getImpl(): int + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt new file mode 100644 index 00000000000..cec69c5a74e --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt @@ -0,0 +1,12 @@ +// CHECK_BYTECODE_LISTING + +//FILE file1.kt +val impl = 123 + +//FILE file2.kt +operator fun Any?.getValue(thisRef: Any?, property: Any?) = + if (this == 123 && thisRef == null) "OK" else "Failed" + +val s: String by impl + +fun box() = s \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.txt new file mode 100644 index 00000000000..e356a762cd3 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.txt @@ -0,0 +1,12 @@ +@kotlin.Metadata +public final class FinalPropertyInAnotherFileKt { + // source: 'finalPropertyInAnotherFile.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static field impl: int + private final static field s$delegate: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getImpl(): int + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile_ir.txt new file mode 100644 index 00000000000..73bbd3cff69 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile_ir.txt @@ -0,0 +1,12 @@ +@kotlin.Metadata +public final class FinalPropertyInAnotherFileKt { + // source: 'finalPropertyInAnotherFile.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static field impl: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getImpl(): int + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt new file mode 100644 index 00000000000..204acb7971d --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt @@ -0,0 +1,18 @@ +// FILE: 1.kt + +var result = "Fail" +val unused by c + +fun box(): String = result + +// FILE: 2.kt + +class C { + init { + result = "OK" + } +} + +operator fun C.getValue(x: Any?, y: Any?): String = throw IllegalStateException() + +val c = C() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt new file mode 100644 index 00000000000..28cb40cfe03 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt @@ -0,0 +1,18 @@ +// CHECK_BYTECODE_LISTING + +import O.d + +enum class E { X } + +object O { + val E.d: Delegate get() = Delegate() +} + +class Delegate { + operator fun getValue(thisRef: Any?, property: Any?) = + if (thisRef == null) "OK" else "Failed" +} + +val result by E.X.d + +fun box(): String = result diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.txt new file mode 100644 index 00000000000..bf07111048b --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.txt @@ -0,0 +1,36 @@ +@kotlin.Metadata +public final class Delegate { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + private synthetic final static field $VALUES: E[] + public final enum static field X: E + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} + +@kotlin.Metadata +public final class MemberExtensionPropertyAndImportFromObjectKt { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static @org.jetbrains.annotations.NotNull field result$delegate: Delegate + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject_ir.txt new file mode 100644 index 00000000000..f3a123baadc --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject_ir.txt @@ -0,0 +1,37 @@ +@kotlin.Metadata +public final class Delegate { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + private synthetic final static field $VALUES: E[] + public final enum static field X: E + private synthetic final static method $values(): E[] + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} + +@kotlin.Metadata +public final class MemberExtensionPropertyAndImportFromObjectKt { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static @org.jetbrains.annotations.NotNull field result$delegate: Delegate + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'memberExtensionPropertyAndImportFromObject.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt new file mode 100644 index 00000000000..da75dca67f1 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt @@ -0,0 +1,17 @@ +// CHECK_BYTECODE_LISTING + +enum class E { X } + +object O { + val E.d: Delegate get() = Delegate() +} + +class Delegate { + operator fun getValue(thisRef: Any?, property: Any?) = + if (thisRef == null) "OK" else "Failed" +} + +fun box(): String = with(O) { + val result by E.X.d + result +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.txt new file mode 100644 index 00000000000..7b220258202 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.txt @@ -0,0 +1,34 @@ +@kotlin.Metadata +public final class Delegate { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + private synthetic final static field $VALUES: E[] + public final enum static field X: E + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} + +@kotlin.Metadata +public final class MemberExtensionPropertyAndLocalDelegatedPropertyKt { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty_ir.txt new file mode 100644 index 00000000000..603595c0a2a --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty_ir.txt @@ -0,0 +1,36 @@ +@kotlin.Metadata +public final class Delegate { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + private synthetic final static field $VALUES: E[] + public final enum static field X: E + private synthetic final static method $values(): E[] + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} + +@kotlin.Metadata +public final class MemberExtensionPropertyAndLocalDelegatedPropertyKt { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + private final static method box$lambda-1$lambda-0(p0: Delegate): java.lang.String + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt new file mode 100644 index 00000000000..e67b1631e7a --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// CHECK_BYTECODE_LISTING + +// MODULE: lib +// FILE: file1.kt +val impl = 123 + +// MODULE: main(lib) +// FILE: file2.kt +operator fun Any?.getValue(thisRef: Any?, property: Any?) = "OK" + +val s: String by impl + +fun box() = s \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.txt new file mode 100644 index 00000000000..8dafa3d45f9 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.txt @@ -0,0 +1,19 @@ +Module: lib +@kotlin.Metadata +public final class File1Kt { + // source: 'file1.kt' + private final static field impl: int + static method (): void + public final static method getImpl(): int +} +Module: main +@kotlin.Metadata +public final class File2Kt { + // source: 'file2.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static field s$delegate: int + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt new file mode 100644 index 00000000000..80c8716809d --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt @@ -0,0 +1,13 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +enum class E { + OK, NOT_OK +} + +operator fun E.getValue(thisRef: Any?, property: Any?): String = + if (this == E.OK && thisRef == null) "OK" else "Failed" + +val s: String by E.OK + +fun box(): String = s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.txt new file mode 100644 index 00000000000..99d6a886185 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.txt @@ -0,0 +1,22 @@ +@kotlin.Metadata +public final class DelegateToEnumKt { + // source: 'delegateToEnum.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static @org.jetbrains.annotations.NotNull field s$delegate: E + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'delegateToEnum.kt' + private synthetic final static field $VALUES: E[] + public final enum static field NOT_OK: E + public final enum static field OK: E + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt new file mode 100644 index 00000000000..68c7a1d9714 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt @@ -0,0 +1,17 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +enum class E { + OK, NOT_OK +} + +class C { + val s: String by E.OK +} + +val c = C() + +operator fun E.getValue(thisRef: Any?, property: Any?): String = + if (this == E.OK && thisRef == c) "OK" else "Failed" + +fun box(): String = c.s diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.txt new file mode 100644 index 00000000000..94a0bdf684e --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.txt @@ -0,0 +1,31 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToEnumInAClass.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final @org.jetbrains.annotations.NotNull field s$delegate: E + static method (): void + public method (): void + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToEnumInAClassKt { + // source: 'delegateToEnumInAClass.kt' + private final static @org.jetbrains.annotations.NotNull field c: C + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getC(): C + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'delegateToEnumInAClass.kt' + private synthetic final static field $VALUES: E[] + public final enum static field NOT_OK: E + public final enum static field OK: E + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass_ir.txt new file mode 100644 index 00000000000..d9b2641f7a6 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass_ir.txt @@ -0,0 +1,32 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToEnumInAClass.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public method (): void + private static method getS$delegate(p0: C): java.lang.Object + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToEnumInAClassKt { + // source: 'delegateToEnumInAClass.kt' + private final static @org.jetbrains.annotations.NotNull field c: C + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getC(): C + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'delegateToEnumInAClass.kt' + private synthetic final static field $VALUES: E[] + public final enum static field NOT_OK: E + public final enum static field OK: E + private synthetic final static method $values(): E[] + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum_ir.txt new file mode 100644 index 00000000000..1cffb20f649 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum_ir.txt @@ -0,0 +1,23 @@ +@kotlin.Metadata +public final class DelegateToEnumKt { + // source: 'delegateToEnum.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final enum class E { + // source: 'delegateToEnum.kt' + private synthetic final static field $VALUES: E[] + public final enum static field NOT_OK: E + public final enum static field OK: E + private synthetic final static method $values(): E[] + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt new file mode 100644 index 00000000000..444205e8294 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt @@ -0,0 +1,25 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING +// IGNORE_BACKEND: JS_IR + +import kotlin.reflect.KProperty +import kotlin.test.assertEquals + +object Store { + private val map = mutableMapOf>, String?>() + + operator fun getValue(thisRef: Any?, property: KProperty<*>): String? = map[thisRef to property] + + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) { + map[thisRef to property] = value + } +} + +object O { + var s: String? by Store +} + +fun box(): String? { + O.s = "OK" + return O.s +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.txt new file mode 100644 index 00000000000..fc6234ef933 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +public final class DelegateToSingletonKt { + // source: 'delegateToSingleton.kt' + public final static @org.jetbrains.annotations.Nullable method box(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'delegateToSingleton.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + private final static @org.jetbrains.annotations.Nullable field s$delegate: Store + static method (): void + private method (): void + public final @org.jetbrains.annotations.Nullable method getS(): java.lang.String + public final method setS(@org.jetbrains.annotations.Nullable p0: java.lang.String): void +} + +@kotlin.Metadata +public final class Store { + // source: 'delegateToSingleton.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: Store + private final static field map: java.util.Map + static method (): void + private method (): void + public final @org.jetbrains.annotations.Nullable method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty): java.lang.String + public final method setValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty, @org.jetbrains.annotations.Nullable p2: java.lang.String): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton_ir.txt new file mode 100644 index 00000000000..dd9278f7f89 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton_ir.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +public final class DelegateToSingletonKt { + // source: 'delegateToSingleton.kt' + public final static @org.jetbrains.annotations.Nullable method box(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'delegateToSingleton.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + private static method getS$delegate(p0: O): java.lang.Object + public final @org.jetbrains.annotations.Nullable method getS(): java.lang.String + public final method setS(@org.jetbrains.annotations.Nullable p0: java.lang.String): void +} + +@kotlin.Metadata +public final class Store { + // source: 'delegateToSingleton.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: Store + private final static @org.jetbrains.annotations.NotNull field map: java.util.Map + static method (): void + private method (): void + public final @org.jetbrains.annotations.Nullable method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty): java.lang.String + public final method setValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty, @org.jetbrains.annotations.Nullable p2: java.lang.String): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt new file mode 100644 index 00000000000..e9ce0913148 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt @@ -0,0 +1,15 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +object O { + object P + init { + throw IllegalStateException("O should not be initialized") + } +} + +operator fun O.P.getValue(thisRef: Any?, property: Any?) = if (thisRef == null) "OK" else "Failed" + +val result by O.P + +fun box(): String = result \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.txt new file mode 100644 index 00000000000..39b97d345d2 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +public final class NoInitializationOfOuterClassKt { + // source: 'noInitializationOfOuterClass.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final static @org.jetbrains.annotations.NotNull field result$delegate: O$P + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: O$P, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class O$P { + // source: 'noInitializationOfOuterClass.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O$P + static method (): void + private method (): void + public final inner class O$P +} + +@kotlin.Metadata +public final class O { + // source: 'noInitializationOfOuterClass.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final inner class O$P +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass_ir.txt new file mode 100644 index 00000000000..f3bf2993ee4 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass_ir.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +public final class NoInitializationOfOuterClassKt { + // source: 'noInitializationOfOuterClass.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + private static method getResult$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: O$P, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class O$P { + // source: 'noInitializationOfOuterClass.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O$P + static method (): void + private method (): void + public final inner class O$P +} + +@kotlin.Metadata +public final class O { + // source: 'noInitializationOfOuterClass.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final inner class O$P +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt new file mode 100644 index 00000000000..b63dc74b51b --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt @@ -0,0 +1,23 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +var initialized = false + +object O { + init { + initialized = true + } + + operator fun getValue(x: Any?, y: Any?): String { + throw RuntimeException() + } +} + +class C { + val s: String by O +} + +fun box(): String { + val c = C() + return if (initialized) "OK" else "FAILURE" +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.txt new file mode 100644 index 00000000000..2521f666a15 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.txt @@ -0,0 +1,27 @@ +@kotlin.Metadata +public final class C { + // source: 'withSideEffects.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final @org.jetbrains.annotations.NotNull field s$delegate: O + static method (): void + public method (): void + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'withSideEffects.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class WithSideEffectsKt { + // source: 'withSideEffects.kt' + private static field initialized: boolean + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getInitialized(): boolean + public final static method setInitialized(p0: boolean): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt new file mode 100644 index 00000000000..6999763b247 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt @@ -0,0 +1,19 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +var initialized = false + +object O { + init { + initialized = true + } + + operator fun getValue(x: Any?, y: Any?): String { + throw RuntimeException() + } +} + +val s: String by O + +fun box(): String = if (initialized) "OK" else "FAILURE" + diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.txt new file mode 100644 index 00000000000..c887692e1b9 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.txt @@ -0,0 +1,21 @@ +@kotlin.Metadata +public final class O { + // source: 'withSideEffectsFromFileClass.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class WithSideEffectsFromFileClassKt { + // source: 'withSideEffectsFromFileClass.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private static field initialized: boolean + private final static @org.jetbrains.annotations.NotNull field s$delegate: O + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getInitialized(): boolean + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static method setInitialized(p0: boolean): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass_ir.txt new file mode 100644 index 00000000000..5dbfcd94534 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass_ir.txt @@ -0,0 +1,21 @@ +@kotlin.Metadata +public final class O { + // source: 'withSideEffectsFromFileClass.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class WithSideEffectsFromFileClassKt { + // source: 'withSideEffectsFromFileClass.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private static field initialized: boolean + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getInitialized(): boolean + private static method getS$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final static method setInitialized(p0: boolean): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt new file mode 100644 index 00000000000..7c53ad061b8 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt @@ -0,0 +1,22 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +var initialized = false + +enum class E { + X; + + companion object { + init { + initialized = true + } + } +} + +operator fun Any?.getValue(x: Any?, y: Any?): String { + throw RuntimeException() +} + +val result by E.X + +fun box() = if (initialized) "OK" else "FAILURE" diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.txt new file mode 100644 index 00000000000..96a6f9a9e59 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.txt @@ -0,0 +1,34 @@ +@kotlin.Metadata +public final class E$Companion { + // source: 'withSideEffectsToEnum.kt' + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void + public final inner class E$Companion +} + +@kotlin.Metadata +public final enum class E { + // source: 'withSideEffectsToEnum.kt' + private synthetic final static field $VALUES: E[] + public final static @org.jetbrains.annotations.NotNull field Companion: E$Companion + public final enum static field X: E + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] + public final inner class E$Companion +} + +@kotlin.Metadata +public final class WithSideEffectsToEnumKt { + // source: 'withSideEffectsToEnum.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private static field initialized: boolean + private final static @org.jetbrains.annotations.NotNull field result$delegate: E + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getInitialized(): boolean + public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String + public final static method setInitialized(p0: boolean): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum_ir.txt new file mode 100644 index 00000000000..31291a5aec9 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum_ir.txt @@ -0,0 +1,35 @@ +@kotlin.Metadata +public final class E$Companion { + // source: 'withSideEffectsToEnum.kt' + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void + public final inner class E$Companion +} + +@kotlin.Metadata +public final enum class E { + // source: 'withSideEffectsToEnum.kt' + private synthetic final static field $VALUES: E[] + public final static @org.jetbrains.annotations.NotNull field Companion: E$Companion + public final enum static field X: E + private synthetic final static method $values(): E[] + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): E + public static method values(): E[] + public final inner class E$Companion +} + +@kotlin.Metadata +public final class WithSideEffectsToEnumKt { + // source: 'withSideEffectsToEnum.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private static field initialized: boolean + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getInitialized(): boolean + private static method getResult$delegate(): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String + public final static method setInitialized(p0: boolean): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects_ir.txt new file mode 100644 index 00000000000..be7a18d4301 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects_ir.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +public final class C { + // source: 'withSideEffects.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public method (): void + private static method getS$delegate(p0: C): java.lang.Object + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class O { + // source: 'withSideEffects.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: O + static method (): void + private method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class WithSideEffectsKt { + // source: 'withSideEffects.kt' + private static field initialized: boolean + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static method getInitialized(): boolean + public final static method setInitialized(p0: boolean): void +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt new file mode 100644 index 00000000000..6860ec2eb4c --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt @@ -0,0 +1,13 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +class O { + operator fun getValue(thisRef: Any?, property: Any?) = + if (thisRef is I) "OK" else "Failed" + + inner class I { + val s: String by this@O + } +} + +fun box() = O().I().s \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.txt new file mode 100644 index 00000000000..733fe3454d0 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.txt @@ -0,0 +1,25 @@ +@kotlin.Metadata +public final class DelegateToOuterThisKt { + // source: 'delegateToOuterThis.kt' + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} + +@kotlin.Metadata +public final class O$I { + // source: 'delegateToOuterThis.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final @org.jetbrains.annotations.NotNull field s$delegate: O + synthetic final field this$0: O + static method (): void + public method (p0: O): void + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final inner class O$I +} + +@kotlin.Metadata +public final class O { + // source: 'delegateToOuterThis.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String + public final inner class O$I +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis_ir.txt new file mode 100644 index 00000000000..ee60d3bc52b --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis_ir.txt @@ -0,0 +1,25 @@ +@kotlin.Metadata +public final class DelegateToOuterThisKt { + // source: 'delegateToOuterThis.kt' + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} + +@kotlin.Metadata +public final class O$I { + // source: 'delegateToOuterThis.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + synthetic final field this$0: O + static method (): void + public method (p0: O): void + private static method getS$delegate(p0: O$I): java.lang.Object + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final inner class O$I +} + +@kotlin.Metadata +public final class O { + // source: 'delegateToOuterThis.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String + public final inner class O$I +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt new file mode 100644 index 00000000000..24dfa08a8f3 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt @@ -0,0 +1,11 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +class C { + operator fun getValue(thisRef: Any?, property: Any?) = + if (thisRef == this) "OK" else "Failed" + + val s: String by this +} + +fun box() = C().s \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.txt new file mode 100644 index 00000000000..73b2962e9c5 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.txt @@ -0,0 +1,16 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToThis.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final @org.jetbrains.annotations.NotNull field s$delegate: C + static method (): void + public method (): void + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToThisKt { + // source: 'delegateToThis.kt' + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt new file mode 100644 index 00000000000..a4616542b77 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt @@ -0,0 +1,13 @@ +// WITH_STDLIB +// CHECK_BYTECODE_LISTING + +class C { + val s: String by this +} + +val c = C() + +operator fun C.getValue(thisRef: Any?, property: Any?) = + if (this == c && thisRef == c) "OK" else "Failed" + +fun box() = c.s \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.txt new file mode 100644 index 00000000000..e64170f3c02 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.txt @@ -0,0 +1,19 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToThisByExtension.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + private final @org.jetbrains.annotations.NotNull field s$delegate: C + static method (): void + public method (): void + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToThisByExtensionKt { + // source: 'delegateToThisByExtension.kt' + private final static @org.jetbrains.annotations.NotNull field c: C + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getC(): C + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: C, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension_ir.txt new file mode 100644 index 00000000000..8d97ed7c514 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension_ir.txt @@ -0,0 +1,19 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToThisByExtension.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public method (): void + private static method getS$delegate(p0: C): java.lang.Object + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToThisByExtensionKt { + // source: 'delegateToThisByExtension.kt' + private final static @org.jetbrains.annotations.NotNull field c: C + static method (): void + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method getC(): C + public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: C, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis_ir.txt b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis_ir.txt new file mode 100644 index 00000000000..619b0ce515a --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis_ir.txt @@ -0,0 +1,16 @@ +@kotlin.Metadata +public final class C { + // source: 'delegateToThis.kt' + synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] + static method (): void + public method (): void + private static method getS$delegate(p0: C): java.lang.Object + public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String + public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String +} + +@kotlin.Metadata +public final class DelegateToThisKt { + // source: 'delegateToThis.kt' + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} diff --git a/compiler/testData/codegen/box/jvmName/propertyAccessorsUseSite.kt b/compiler/testData/codegen/box/jvmName/propertyAccessorsUseSite.kt index 003366584ec..58043ca424f 100644 --- a/compiler/testData/codegen/box/jvmName/propertyAccessorsUseSite.kt +++ b/compiler/testData/codegen/box/jvmName/propertyAccessorsUseSite.kt @@ -22,7 +22,7 @@ object Delegate { fun box(): String { assertEquals( listOf("getIsFries", "getIsUpdateable", "setIsFries", "setIsUpdateable"), - TestIt::class.java.declaredMethods.map { it.name }.sorted() + TestIt::class.java.declaredMethods.map { it.name }.sorted() - "getIsUpdateable\$delegate" ) return "OK" diff --git a/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt new file mode 100644 index 00000000000..1e6ab02e2c8 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt @@ -0,0 +1,17 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.reflect.jvm.isAccessible + +operator fun Any?.getValue(x: Any?, y: Any?): String { + return "OK" +} + +val s: String by 1 + +fun box(): String { + assertEquals(1, ::s.apply { isAccessible = true }.getDelegate()) + return "OK" +} + diff --git a/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt new file mode 100644 index 00000000000..1091f3706a6 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.jvm.isAccessible +import kotlin.test.assertEquals + +operator fun Any?.getValue(x: Any?, y: Any?): String { + return "OK" +} +const val a = "TEXT" + +val s: String by a + +fun box(): String { + assertEquals("TEXT", ::s.apply { isAccessible = true }.getDelegate()) + return "OK" +} + diff --git a/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt new file mode 100644 index 00000000000..8fdab4169fc --- /dev/null +++ b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.reflect.jvm.isAccessible + +enum class E { + OK, NOT_OK +} + +operator fun E.getValue(x: Any?, y: Any?): String = name + +val s: String by E.OK + +fun box(): String { + assertEquals(E.OK, ::s.apply { isAccessible = true }.getDelegate()) + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt new file mode 100644 index 00000000000..5b158aa31e0 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty +import kotlin.reflect.jvm.isAccessible + +import kotlin.test.assertEquals + +object O { + val impl = 123 +} + +operator fun Any?.getValue(thisRef: Any?, property: KProperty<*>) = "OK" + +val s: String by O.impl + +fun box(): String { + assertEquals(123, ::s.apply { isAccessible = true }.getDelegate()) + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt new file mode 100644 index 00000000000..f3525729e1f --- /dev/null +++ b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.KProperty +import kotlin.reflect.jvm.isAccessible + +import kotlin.test.assertEquals + +val impl = 123 + +operator fun Any?.getValue(thisRef: Any?, property: KProperty<*>) = "OK" + +val s: String by impl + +fun box(): String { + assertEquals(123, ::s.apply { isAccessible = true }.getDelegate()) + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt new file mode 100644 index 00000000000..f0c393bf24a --- /dev/null +++ b/compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt @@ -0,0 +1,27 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.KProperty +import kotlin.reflect.jvm.isAccessible + +import kotlin.test.assertEquals + +object Store { + private val map = mutableMapOf>, String?>() + + operator fun getValue(thisRef: Any?, property: KProperty<*>): String? = map[thisRef to property] + + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) { + map[thisRef to property] = value + } +} + +object O { + var s: String? by Store +} + +fun box(): String { + assertEquals(Store, O::s.apply { isAccessible = true }.getDelegate()) + return "OK" +} + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 22e94a57e0f..98661efe6a6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -14477,6 +14477,178 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToConst { + @Test + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToFinalProperty { + @Test + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @Test + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @Test + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + + @Test + @TestMetadata("multimodule.kt") + public void testMultimodule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToSingleton { + @Test + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @Test + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @Test + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @Test + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @Test + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToThis { + @Test + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @Test + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @Test + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT") @@ -42287,6 +42459,42 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testDelegateToAnother() throws Exception { runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt"); } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt"); + } } } 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 a92f0dddbc2..b4387fdf079 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 @@ -14597,6 +14597,178 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToConst { + @Test + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToFinalProperty { + @Test + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @Test + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @Test + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + + @Test + @TestMetadata("multimodule.kt") + public void testMultimodule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToSingleton { + @Test + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @Test + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @Test + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @Test + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @Test + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToThis { + @Test + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @Test + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @Test + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT") @@ -42815,6 +42987,42 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testDelegateToAnother() throws Exception { runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt"); } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt"); + } } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 44f020f4804..c4d47933e03 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11809,6 +11809,168 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToConst extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToFinalProperty extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + + @TestMetadata("multimodule.kt") + public void testMultimodule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/multimodule.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToSingleton extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToThis extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -34018,6 +34180,36 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testDelegateToAnother() throws Exception { runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt"); } + + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConst.kt"); + } + + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToConstProperty.kt"); + } + + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToEnum.kt"); + } + + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalObjectProperty.kt"); + } + + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToFinalProperty.kt"); + } + + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToSingleton.kt"); + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 98718c5eb60..6d8ea4a740e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -11041,6 +11041,172 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToConst { + @Test + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToFinalProperty { + @Test + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @Test + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @Test + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @Test + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToSingleton { + @Test + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @Test + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @Test + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @Test + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @Test + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToThis { + @Test + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @Test + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @Test + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @Test + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index fcfa7f8743f..eeb15dfaa34 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -11083,6 +11083,172 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToConst { + @Test + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToFinalProperty { + @Test + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @Test + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @Test + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToSingleton { + @Test + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @Test + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @Test + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @Test + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @Test + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + public class DelegateToThis { + @Test + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @Test + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @Test + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index ee45a53d2a1..26e70bd0c55 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -9804,6 +9804,163 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToConst extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToFinalProperty extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToSingleton extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DelegateToThis extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/libraries/tools/kotlinp/testData/Properties.txt b/libraries/tools/kotlinp/testData/Properties.txt index 0ea3ff5a2ec..e6a133f4ed4 100644 --- a/libraries/tools/kotlinp/testData/Properties.txt +++ b/libraries/tools/kotlinp/testData/Properties.txt @@ -35,8 +35,8 @@ public final class C : kotlin/Any { public final /* delegated */ val withOptimizedDelegate: kotlin/Double public final /* non-default */ get - // field: delegated$delegate:Ljava/lang/Void; // getter: getDelegated(Ljava/lang/Number;)Ljava/util/List; + // synthetic method for delegate: getDelegated$delegate(LC;Ljava/lang/Number;)Ljava/lang/Object; public final /* delegated */ val T#0.delegated: kotlin/collections/List public final /* non-default */ get diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index cc9d51cb6c5..a27f8e45e79 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -12043,6 +12043,180 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest } } + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToConst") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @UseExtTestCaseGroupProvider() + public class DelegateToConst { + @Test + public void testAllFilesPresentInDelegateToConst() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToConst"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("delegateToConst.kt") + public void testDelegateToConst() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConst.kt"); + } + + @Test + @TestMetadata("delegateToConstProperty.kt") + public void testDelegateToConstProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToConstProperty.kt"); + } + + @Test + @TestMetadata("delegateToNull.kt") + public void testDelegateToNull() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToConst/delegateToNull.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @UseExtTestCaseGroupProvider() + public class DelegateToFinalProperty { + @Test + public void testAllFilesPresentInDelegateToFinalProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("chain.kt") + public void testChain() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/chain.kt"); + } + + @Test + @TestMetadata("delegateToFinalInstanceProperty.kt") + public void testDelegateToFinalInstanceProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalInstanceProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalObjectProperty.kt") + public void testDelegateToFinalObjectProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalObjectProperty.kt"); + } + + @Test + @TestMetadata("delegateToFinalProperty.kt") + public void testDelegateToFinalProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/delegateToFinalProperty.kt"); + } + + @Test + @TestMetadata("finalPropertyInAnotherFile.kt") + public void testFinalPropertyInAnotherFile() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/finalPropertyInAnotherFile.kt"); + } + + @Test + @TestMetadata("initializeContainerOfTopLevelProperties.kt") + public void testInitializeContainerOfTopLevelProperties() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/initializeContainerOfTopLevelProperties.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndImportFromObject.kt") + public void testMemberExtensionPropertyAndImportFromObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndImportFromObject.kt"); + } + + @Test + @TestMetadata("memberExtensionPropertyAndLocalDelegatedProperty.kt") + public void testMemberExtensionPropertyAndLocalDelegatedProperty() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToFinalProperty/memberExtensionPropertyAndLocalDelegatedProperty.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @UseExtTestCaseGroupProvider() + public class DelegateToSingleton { + @Test + public void testAllFilesPresentInDelegateToSingleton() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("delegateToEnum.kt") + public void testDelegateToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnum.kt"); + } + + @Test + @TestMetadata("delegateToEnumInAClass.kt") + public void testDelegateToEnumInAClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToEnumInAClass.kt"); + } + + @Test + @TestMetadata("delegateToSingleton.kt") + public void testDelegateToSingleton() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/delegateToSingleton.kt"); + } + + @Test + @TestMetadata("noInitializationOfOuterClass.kt") + public void testNoInitializationOfOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/noInitializationOfOuterClass.kt"); + } + + @Test + @TestMetadata("withSideEffects.kt") + public void testWithSideEffects() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffects.kt"); + } + + @Test + @TestMetadata("withSideEffectsFromFileClass.kt") + public void testWithSideEffectsFromFileClass() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsFromFileClass.kt"); + } + + @Test + @TestMetadata("withSideEffectsToEnum.kt") + public void testWithSideEffectsToEnum() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToSingleton/withSideEffectsToEnum.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/delegatedProperty/delegateToThis") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @UseExtTestCaseGroupProvider() + public class DelegateToThis { + @Test + public void testAllFilesPresentInDelegateToThis() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/delegatedProperty/delegateToThis"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("delegateToOuterThis.kt") + public void testDelegateToOuterThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToOuterThis.kt"); + } + + @Test + @TestMetadata("delegateToThis.kt") + public void testDelegateToThis() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThis.kt"); + } + + @Test + @TestMetadata("delegateToThisByExtension.kt") + public void testDelegateToThisByExtension() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToThis/delegateToThisByExtension.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/delegatedProperty/local") @TestDataPath("$PROJECT_ROOT")