[IR] Implement getContextReceiverParameters for IrBasedPropertyDescriptor

Fixes: KT-59590
This commit is contained in:
Xin Wang
2023-08-24 17:33:32 +08:00
committed by Space Team
parent 03ad981dea
commit 51325ba630
11 changed files with 126 additions and 2 deletions
@@ -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")
@@ -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")
@@ -902,7 +902,7 @@ open class IrBasedPropertyDescriptor(owner: IrProperty) :
owner.getter?.extensionReceiverParameter?.toIrBasedDescriptor() as? ReceiverParameterDescriptor
override fun getContextReceiverParameters(): List<ReceiverParameterDescriptor> {
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<ReceiverParameterDescriptor> {
TODO("Not yet implemented")
return owner.correspondingPropertySymbol?.owner?.toIrBasedDescriptor()?.contextReceiverParameters ?: emptyList()
}
override fun isExternal() = owner.isExternal
@@ -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
@@ -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
@@ -0,0 +1,8 @@
// FIR_IDENTICAL
// WITH_STDLIB
// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT
<!CONFLICTING_JVM_DECLARATIONS!>object O {
<!CONFLICTING_JVM_DECLARATIONS!>@JvmField
val INSTANCE: O? = null<!>
}<!>
@@ -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
@@ -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
@@ -0,0 +1,8 @@
// WITH_STDLIB
// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT
<!CONFLICTING_JVM_DECLARATIONS!>object O {
<!CONFLICTING_JVM_DECLARATIONS!>context(O)
@JvmField
val INSTANCE: O? = null<!>
}<!>
@@ -0,0 +1,8 @@
// WITH_STDLIB
// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT
<!CONFLICTING_JVM_DECLARATIONS!>object O {
<!CONFLICTING_JVM_DECLARATIONS!><!UNSUPPORTED_FEATURE, UNSUPPORTED_FEATURE!>context(O)<!>
@JvmField
val INSTANCE: O? = <!CONTEXT_RECEIVERS_WITH_BACKING_FIELD!>null<!><!>
}<!>
@@ -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")