diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java index f03d8bce30e..b8a001623ac 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java @@ -78,6 +78,28 @@ public class FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated extends Abstra runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspensionPointInMonitor.kt"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers") + @TestDataPath("$PROJECT_ROOT") + public class ContextReceivers { + @Test + public void testAllFilesPresentInContextReceivers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("kt59590.kt") + public void testKt59590() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.kt"); + } + + @Test + @TestMetadata("kt59590WithContextReceiver.kt") + public void testKt59590WithContextReceiver() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java index 56c16797655..db332e69847 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java @@ -78,6 +78,28 @@ public class FirPsiDiagnosticsTestWithJvmIrBackendGenerated extends AbstractFirP runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspensionPointInMonitor.kt"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers") + @TestDataPath("$PROJECT_ROOT") + public class ContextReceivers { + @Test + public void testAllFilesPresentInContextReceivers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("kt59590.kt") + public void testKt59590() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.kt"); + } + + @Test + @TestMetadata("kt59590WithContextReceiver.kt") + public void testKt59590WithContextReceiver() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt index 563c5ae7346..aca8868a00a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt @@ -902,7 +902,7 @@ open class IrBasedPropertyDescriptor(owner: IrProperty) : owner.getter?.extensionReceiverParameter?.toIrBasedDescriptor() as? ReceiverParameterDescriptor override fun getContextReceiverParameters(): List { - TODO("Not yet implemented") + return getter?.contextReceiverParameters ?: emptyList() } override fun isExternal() = owner.isExternal @@ -1098,7 +1098,7 @@ open class IrBasedFieldDescriptor(owner: IrField) : PropertyDescriptor, IrBasedD owner.correspondingPropertySymbol?.owner?.toIrBasedDescriptor()?.extensionReceiverParameter override fun getContextReceiverParameters(): List { - TODO("Not yet implemented") + return owner.correspondingPropertySymbol?.owner?.toIrBasedDescriptor()?.contextReceiverParameters ?: emptyList() } override fun isExternal() = owner.isExternal diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.diag.txt b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.diag.txt new file mode 100644 index 00000000000..e1910b1330e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.diag.txt @@ -0,0 +1,7 @@ +/kt59590.kt:5:1: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + val INSTANCE: O? defined in O + val INSTANCE: O defined in O + +/kt59590.kt:6:5: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + val INSTANCE: O? defined in O + val INSTANCE: O defined in O diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.fir.diag.txt b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.fir.diag.txt new file mode 100644 index 00000000000..ee8c877251f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.fir.diag.txt @@ -0,0 +1,7 @@ +/kt59590.fir.kt:4:1: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + val INSTANCE: O? defined in O + val INSTANCE: O defined in O + +/kt59590.fir.kt:5:5: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + val INSTANCE: O? defined in O + val INSTANCE: O defined in O diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.kt b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.kt new file mode 100644 index 00000000000..05f56cf5d68 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.kt @@ -0,0 +1,8 @@ +// FIR_IDENTICAL +// WITH_STDLIB +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT + +object O { + @JvmField + val INSTANCE: O? = null +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.diag.txt b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.diag.txt new file mode 100644 index 00000000000..fc959a97dcf --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.diag.txt @@ -0,0 +1,13 @@ +/kt59590WithContextReceiver.kt:4:1: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + context(O) val INSTANCE: O? defined in O + val INSTANCE: O defined in O + +/kt59590WithContextReceiver.kt:5:5: error: The feature "context receivers" is experimental and should be enabled explicitly + +/kt59590WithContextReceiver.kt:5:5: error: The feature "context receivers" is experimental and should be enabled explicitly + +/kt59590WithContextReceiver.kt:5:5: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + context(O) val INSTANCE: O? defined in O + val INSTANCE: O defined in O + +/kt59590WithContextReceiver.kt:7:24: error: Property with context receivers cannot be initialized because it has no backing field diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.fir.diag.txt b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.fir.diag.txt new file mode 100644 index 00000000000..73cd54a9214 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.fir.diag.txt @@ -0,0 +1,7 @@ +/kt59590WithContextReceiver.fir.kt:4:1: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + context(O) val INSTANCE: O? defined in O + val INSTANCE: O defined in O + +/kt59590WithContextReceiver.fir.kt:5:5: error: Platform declaration clash: The following declarations have the same JVM signature (INSTANCELO;): + context(O) val INSTANCE: O? defined in O + val INSTANCE: O defined in O diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.fir.kt b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.fir.kt new file mode 100644 index 00000000000..8de38f0f016 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.fir.kt @@ -0,0 +1,8 @@ +// WITH_STDLIB +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT + +object O { + context(O) + @JvmField + val INSTANCE: O? = null +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.kt b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.kt new file mode 100644 index 00000000000..e17f4115c17 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.kt @@ -0,0 +1,8 @@ +// WITH_STDLIB +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT + +object O { + context(O) + @JvmField + val INSTANCE: O? = null +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java index af12cb0aba8..33715c77b4e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java @@ -79,6 +79,28 @@ public class DiagnosticsTestWithJvmIrBackendGenerated extends AbstractDiagnostic runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspensionPointInMonitor.kt"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers") + @TestDataPath("$PROJECT_ROOT") + public class ContextReceivers { + @Test + public void testAllFilesPresentInContextReceivers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers"), Pattern.compile("^(.+)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt59590.kt") + public void testKt59590() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590.kt"); + } + + @Test + @TestMetadata("kt59590WithContextReceiver.kt") + public void testKt59590WithContextReceiver() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/contextReceivers/kt59590WithContextReceiver.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT")