K2: fix property VS field resolve in anonymous class case
Related to KT-55017, KT-50082
This commit is contained in:
committed by
teamcity
parent
6a6308bef2
commit
f20e5daa92
+6
@@ -3589,6 +3589,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldAndKotlinPropertyReferenceFromInner.kt")
|
||||||
|
public void testJavaFieldAndKotlinPropertyReferenceFromInner() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/javaFieldAndKotlinPropertyReferenceFromInner.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyAndTwoFields.kt")
|
@TestMetadata("propertyAndTwoFields.kt")
|
||||||
public void testPropertyAndTwoFields() throws Exception {
|
public void testPropertyAndTwoFields() throws Exception {
|
||||||
|
|||||||
+5
@@ -3166,6 +3166,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("javaFieldAndKotlinPropertyReferenceFromInner.kt")
|
||||||
|
public void testJavaFieldAndKotlinPropertyReferenceFromInner() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/javaFieldAndKotlinPropertyReferenceFromInner.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("propertyAndTwoFields.kt")
|
@TestMetadata("propertyAndTwoFields.kt")
|
||||||
public void testPropertyAndTwoFields() throws Exception {
|
public void testPropertyAndTwoFields() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/propertyAndTwoFields.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/propertyAndTwoFields.kt");
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
FILE: test.kt
|
||||||
|
public final fun box(): R|kotlin/String| {
|
||||||
|
lval x: R|<anonymous>| = object : R|base/Jaba| {
|
||||||
|
private constructor(): R|<anonymous>| {
|
||||||
|
super<R|base/Jaba|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
private final val a: R|kotlin/String| = String(OK)
|
||||||
|
private get(): R|kotlin/String|
|
||||||
|
|
||||||
|
local final inner class S : R|kotlin/Any| {
|
||||||
|
public <anonymous>.constructor(): R|<anonymous>.S| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final fun foo(): R|kotlin/String| {
|
||||||
|
^foo this@R|/<anonymous>|.R|/<anonymous>.a|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final fun bar(): R|kotlin/String| {
|
||||||
|
^bar this@R|/<anonymous>|.R|/<anonymous>.S.S|().R|<local>/foo|()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
^box R|<local>/x|.R|/<anonymous>.bar|()
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
// FILE: Jaba.java
|
||||||
|
|
||||||
|
package base;
|
||||||
|
|
||||||
|
public class Jaba {
|
||||||
|
protected String a = "FAIL";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
import base.Jaba
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val x = object : Jaba() {
|
||||||
|
private val a: String = "OK"
|
||||||
|
inner class S {
|
||||||
|
// Should be resolved to a property
|
||||||
|
fun foo() = a
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() = S().foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
return x.bar()
|
||||||
|
}
|
||||||
+6
@@ -3589,6 +3589,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldAndKotlinPropertyReferenceFromInner.kt")
|
||||||
|
public void testJavaFieldAndKotlinPropertyReferenceFromInner() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/javaFieldAndKotlinPropertyReferenceFromInner.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyAndTwoFields.kt")
|
@TestMetadata("propertyAndTwoFields.kt")
|
||||||
public void testPropertyAndTwoFields() throws Exception {
|
public void testPropertyAndTwoFields() throws Exception {
|
||||||
|
|||||||
+6
@@ -3589,6 +3589,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/fieldPropertyShadow.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldAndKotlinPropertyReferenceFromInner.kt")
|
||||||
|
public void testJavaFieldAndKotlinPropertyReferenceFromInner() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/propertyVsField/javaFieldAndKotlinPropertyReferenceFromInner.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyAndTwoFields.kt")
|
@TestMetadata("propertyAndTwoFields.kt")
|
||||||
public void testPropertyAndTwoFields() throws Exception {
|
public void testPropertyAndTwoFields() throws Exception {
|
||||||
|
|||||||
+2
-1
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls.jvm
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirField
|
import org.jetbrains.kotlin.fir.declarations.FirField
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||||
@@ -84,7 +85,7 @@ class JvmPlatformOverloadsConflictResolver(
|
|||||||
private fun ConeClassLikeLookupTag.strictlyDerivedFrom(other: ConeClassLikeLookupTag): Boolean {
|
private fun ConeClassLikeLookupTag.strictlyDerivedFrom(other: ConeClassLikeLookupTag): Boolean {
|
||||||
if (this == other) return false
|
if (this == other) return false
|
||||||
val session = inferenceComponents.session
|
val session = inferenceComponents.session
|
||||||
val thisClass = this.toFirRegularClassSymbol(session)?.fir ?: return false
|
val thisClass = this.toSymbol(session)?.fir as? FirClass ?: return false
|
||||||
|
|
||||||
return thisClass.isSubclassOf(other, session, isStrict = true)
|
return thisClass.isSubclassOf(other, session, isStrict = true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user