Psi2ir: do not generate default accessor body for expect properties
Because generateDefaultGetterBody/generateDefaultSetterBody reference the property's backing field, which in case of extension properties leads to an error "Unbound symbols not allowed" because extension property cannot have a backing field. In some way, this check is similar to the `isExpect` check in `generatePrimaryConstructor`.
This commit is contained in:
+6
@@ -24540,6 +24540,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectClassInJvmMultifileFacade.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noArgActualConstructor.kt")
|
||||
public void testNoArgActualConstructor() throws Exception {
|
||||
|
||||
+2
-3
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||
import org.jetbrains.kotlin.ir.util.declareSimpleFunctionWithOverrides
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.Name.isValidIdentifier
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.pureEndOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.pureStartOffset
|
||||
@@ -137,8 +136,8 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
private fun generateDefaultAccessorBody(
|
||||
accessor: PropertyAccessorDescriptor,
|
||||
irAccessor: IrSimpleFunction
|
||||
) =
|
||||
if (accessor.modality == Modality.ABSTRACT)
|
||||
): IrBlockBody? =
|
||||
if (accessor.modality == Modality.ABSTRACT || accessor.correspondingProperty.isExpect)
|
||||
null
|
||||
else
|
||||
when (accessor) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// FILE: common.kt
|
||||
|
||||
package test
|
||||
|
||||
expect val v: String
|
||||
|
||||
expect val Char.extensionVal: String
|
||||
|
||||
expect var String.extensionVar: Char
|
||||
|
||||
// FILE: jvm.kt
|
||||
|
||||
package test
|
||||
|
||||
actual val v: String = ""
|
||||
|
||||
actual val Char.extensionVal: String
|
||||
get() = toString()
|
||||
|
||||
actual var String.extensionVar: Char
|
||||
get() = this[0]
|
||||
set(value) {}
|
||||
|
||||
fun box(): String =
|
||||
v + 'O'.extensionVal + "K".extensionVar
|
||||
+6
@@ -24540,6 +24540,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectClassInJvmMultifileFacade.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noArgActualConstructor.kt")
|
||||
public void testNoArgActualConstructor() throws Exception {
|
||||
|
||||
+6
@@ -24540,6 +24540,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectClassInJvmMultifileFacade.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noArgActualConstructor.kt")
|
||||
public void testNoArgActualConstructor() throws Exception {
|
||||
|
||||
+5
@@ -20804,6 +20804,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectClassInJvmMultifileFacade.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noArgActualConstructor.kt")
|
||||
public void testNoArgActualConstructor() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -16377,6 +16377,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("optionalExpectation.kt")
|
||||
public void testOptionalExpectation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/optionalExpectation.kt");
|
||||
|
||||
Generated
+5
@@ -15834,6 +15834,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("optionalExpectation.kt")
|
||||
public void testOptionalExpectation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/optionalExpectation.kt");
|
||||
|
||||
Generated
+5
@@ -15899,6 +15899,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("optionalExpectation.kt")
|
||||
public void testOptionalExpectation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/optionalExpectation.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -9740,6 +9740,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectProperty.kt")
|
||||
public void testExpectProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/expectProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("optionalExpectation.kt")
|
||||
public void testOptionalExpectation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/optionalExpectation.kt");
|
||||
|
||||
Reference in New Issue
Block a user