diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index fb2646cdd0f..439bf125035 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -24152,6 +24152,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt"); } + @Test + @TestMetadata("kt47621.kt") + public void testKt47621() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt"); + } + @Test @TestMetadata("lateinitOnTopLevel.kt") public void testLateinitOnTopLevel() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index c2a623de926..e88bd308c81 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -24152,6 +24152,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt"); } + @Test + @TestMetadata("kt47621.kt") + public void testKt47621() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt"); + } + @Test @TestMetadata("lateinitOnTopLevel.kt") public void testLateinitOnTopLevel() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index cefaed3433d..3e01a51a240 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -24152,6 +24152,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt"); } + @Test + @TestMetadata("kt47621.kt") + public void testKt47621() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt"); + } + @Test @TestMetadata("lateinitOnTopLevel.kt") public void testLateinitOnTopLevel() throws Exception { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedSyntheticExtensionCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedSyntheticExtensionCallChecker.kt index 5b947e11c1b..78c614599c7 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedSyntheticExtensionCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedSyntheticExtensionCallChecker.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3 import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.psi.KtDotQualifiedExpression +import org.jetbrains.kotlin.psi.KtQualifiedExpression import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext import org.jetbrains.kotlin.resolve.calls.context.CallPosition @@ -35,14 +36,14 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor object ProtectedSyntheticExtensionCallChecker : CallChecker { - fun computeSuitableDescriptorAndError( + private fun computeSuitableDescriptorAndError( descriptor: SyntheticJavaPropertyDescriptor, reportOn: PsiElement, context: CallCheckerContext ): Pair> { val callPosition = context.resolutionContext.callPosition val isLeftSide = callPosition is CallPosition.PropertyAssignment - && (callPosition.leftPart as? KtDotQualifiedExpression)?.selectorExpression == reportOn + && (callPosition.leftPart as? KtQualifiedExpression)?.selectorExpression == reportOn val getMethod = descriptor.getMethod val setMethod = descriptor.setMethod val isImprovingDiagnosticsEnabled = diff --git a/compiler/testData/diagnostics/tests/properties/kt47621.fir.kt b/compiler/testData/diagnostics/tests/properties/kt47621.fir.kt new file mode 100644 index 00000000000..e603263149d --- /dev/null +++ b/compiler/testData/diagnostics/tests/properties/kt47621.fir.kt @@ -0,0 +1,23 @@ +// WITH_STDLIB + +// FILE: j/J.java +package j; + +public class J { + public int getX() { return 1; } + protected void setX(int value) { throw new RuntimeException(); } +} + +// FILE: main.kt +import j.* + +class C : J() { + fun foo() { + J()?.x = 1 + } +} + +fun box(): String { + C().foo() + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/properties/kt47621.kt b/compiler/testData/diagnostics/tests/properties/kt47621.kt new file mode 100644 index 00000000000..96c252c73f3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/properties/kt47621.kt @@ -0,0 +1,23 @@ +// WITH_STDLIB + +// FILE: j/J.java +package j; + +public class J { + public int getX() { return 1; } + protected void setX(int value) { throw new RuntimeException(); } +} + +// FILE: main.kt +import j.* + +class C : J() { + fun foo() { + J()?.x = 1 + } +} + +fun box(): String { + C().foo() + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/properties/kt47621.txt b/compiler/testData/diagnostics/tests/properties/kt47621.txt new file mode 100644 index 00000000000..899b4007e53 --- /dev/null +++ b/compiler/testData/diagnostics/tests/properties/kt47621.txt @@ -0,0 +1,25 @@ +package + +public fun box(): kotlin.String + +public final class C : j.J { + public constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun getX(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun setX(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +package j { + + public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getX(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + protected/*protected and package*/ open fun setX(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 81add57ff9e..e589ad99d5e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -24158,6 +24158,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt"); } + @Test + @TestMetadata("kt47621.kt") + public void testKt47621() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt"); + } + @Test @TestMetadata("lateinitOnTopLevel.kt") public void testLateinitOnTopLevel() throws Exception {