[FIR] Fix UNRESOLVED_REFERENCE in callable reference to delegated var

#KT-57204 Fixed
This commit is contained in:
Kirill Rakhman
2023-03-10 18:53:01 +01:00
committed by Space Team
parent d20ad67aa9
commit 471ecf62c8
6 changed files with 46 additions and 1 deletions
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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))
@@ -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 <T> consume(arg: T) {}
fun foo(arg: MakefileSettingsFacade) {
consume<KProperty0<String?>>(arg::cleanTarget)
consume<KMutableProperty0<String?>>(arg::cleanTarget)
}
@@ -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 {