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 75de3c32c51..97d39671466 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 @@ -3859,6 +3859,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt"); } + @Test + @TestMetadata("mutablePropertyViaDelegation.kt") + public void testMutablePropertyViaDelegation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/property/mutablePropertyViaDelegation.kt"); + } + @Test @TestMetadata("propertyFromAbstractSuperClass.kt") public void testPropertyFromAbstractSuperClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index e53b9f4051d..5bce6bcab9c 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -3859,6 +3859,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt"); } + @Test + @TestMetadata("mutablePropertyViaDelegation.kt") + public void testMutablePropertyViaDelegation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/property/mutablePropertyViaDelegation.kt"); + } + @Test @TestMetadata("propertyFromAbstractSuperClass.kt") public void testPropertyFromAbstractSuperClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index d35e47c742b..eb21ecd18f1 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -3865,6 +3865,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt"); } + @Test + @TestMetadata("mutablePropertyViaDelegation.kt") + public void testMutablePropertyViaDelegation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/property/mutablePropertyViaDelegation.kt"); + } + @Test @TestMetadata("propertyFromAbstractSuperClass.kt") public void testPropertyFromAbstractSuperClass() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt index 2e1ade66e68..8ba68bd648a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt @@ -443,7 +443,7 @@ private fun createKPropertyType( private fun FirVariable.canBeMutableReference(candidate: Candidate): Boolean { if (!isVar) return false if (this is FirField) return true - val original = this.unwrapFakeOverrides() + val original = this.unwrapFakeOverridesOrDelegated() return original.source?.kind == KtFakeSourceElementKind.PropertyFromParameter || (original.setter is FirMemberDeclaration && candidate.callInfo.session.visibilityChecker.isVisible(original.setter!!, candidate)) diff --git a/compiler/testData/diagnostics/tests/callableReference/property/mutablePropertyViaDelegation.kt b/compiler/testData/diagnostics/tests/callableReference/property/mutablePropertyViaDelegation.kt new file mode 100644 index 00000000000..b25b9e71790 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/property/mutablePropertyViaDelegation.kt @@ -0,0 +1,21 @@ +// FIR_IDENTICAL + +import kotlin.reflect.KMutableProperty0 +import kotlin.reflect.KProperty0 + +interface MkMutableSharedSettingsHolder { + var cleanTarget: String? +} + +data class MakefileSettingsFacade( + val projectSettings: MkMutableSharedSettingsHolder +): MkMutableSharedSettingsHolder by projectSettings { + var cleanTarget2: String? = "" +} + +fun consume(arg: T) {} + +fun foo(arg: MakefileSettingsFacade) { + consume>(arg::cleanTarget) + consume>(arg::cleanTarget) +} 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 a32abffdabf..f6b157193a5 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 @@ -3865,6 +3865,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt"); } + @Test + @TestMetadata("mutablePropertyViaDelegation.kt") + public void testMutablePropertyViaDelegation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/property/mutablePropertyViaDelegation.kt"); + } + @Test @TestMetadata("propertyFromAbstractSuperClass.kt") public void testPropertyFromAbstractSuperClass() throws Exception {