[PSI2IR] Do not generate property reference setter if inaccessible.
Fixes KT-45064.
This commit is contained in:
committed by
Alexander Udalov
parent
d44799fa78
commit
8852323a76
+6
@@ -3534,6 +3534,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessViaSubclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
|
||||
+2
-5
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isKFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isKSuspendFunctionType
|
||||
import org.jetbrains.kotlin.builtins.*
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.declarations.DescriptorMetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
@@ -382,7 +379,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
||||
generateFunctionReference(startOffset, endOffset, type, symbol, callableDescriptor, typeArguments, origin)
|
||||
}
|
||||
is PropertyDescriptor -> {
|
||||
val mutable = get(BindingContext.VARIABLE, ktElement)?.isVar ?: true
|
||||
val mutable = ReflectionTypes.isNumberedKMutablePropertyType(type)
|
||||
generatePropertyReference(startOffset, endOffset, type, callableDescriptor, typeArguments, origin, mutable)
|
||||
}
|
||||
else ->
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: b.kt
|
||||
import a.A
|
||||
|
||||
class B {
|
||||
fun getValue() = sequenceOf(A()).map(A::value).first()
|
||||
}
|
||||
|
||||
fun box() = B().getValue()
|
||||
|
||||
// FILE: a.kt
|
||||
package a
|
||||
|
||||
class A {
|
||||
var value: String = "OK"
|
||||
private set
|
||||
}
|
||||
+6
@@ -3534,6 +3534,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessViaSubclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
|
||||
+6
@@ -3534,6 +3534,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessViaSubclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
|
||||
+5
@@ -3094,6 +3094,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessViaSubclass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -2324,6 +2324,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessViaSubclass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
Generated
+5
@@ -2324,6 +2324,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessViaSubclass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
Generated
+5
@@ -2324,6 +2324,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessViaSubclass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -1714,6 +1714,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("accessorForPropertyWithPrivateSetter.kt")
|
||||
public void testAccessorForPropertyWithPrivateSetter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/accessorForPropertyWithPrivateSetter.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInProperty() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/property"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user