FIR: Fix incorrect resolution to synthetic property by implicit receiver
When there's an explicit one ^KT-39028 Fixed
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass {
|
||||
public String getFoo() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface A
|
||||
|
||||
val A.foo: Int get() = 1
|
||||
|
||||
fun bar(a: A) {
|
||||
a.foo checkType { _<Int>() } // OK, resolved to extension property
|
||||
}
|
||||
|
||||
fun JavaClass.bar(a: A) {
|
||||
a.foo checkType { _<Int>() }
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
FILE: main.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
}
|
||||
public final val R|A|.foo: R|kotlin/Int|
|
||||
public get(): R|kotlin/Int| {
|
||||
^ Int(1)
|
||||
}
|
||||
public final fun bar(a: R|A|): R|kotlin/Unit| {
|
||||
R|<local>/a|.R|/foo|.R|tests/_checkType/checkType|<R|kotlin/Int|>(checkType@fun R|tests/_checkType/Inv<kotlin/Int>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/Int|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
public final fun R|JavaClass|.bar(a: R|A|): R|kotlin/Unit| {
|
||||
R|<local>/a|.R|/foo|.R|tests/_checkType/checkType|<R|kotlin/Int|>(checkType@fun R|tests/_checkType/Inv<kotlin/Int>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/Int|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
FILE: CHECK_TYPE.kt
|
||||
public final fun <T> checkSubtype(t: R|T|): R|T| {
|
||||
^checkSubtype R|<local>/t|
|
||||
}
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|tests/_checkType/Inv<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| {
|
||||
}
|
||||
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
Generated
+5
@@ -634,6 +634,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticPropertiesWrongImplicitReceiver.kt")
|
||||
public void testSyntheticPropertiesWrongImplicitReceiver() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/syntheticPropertiesWrongImplicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasWithNotNullBound.kt")
|
||||
public void testTypeAliasWithNotNullBound() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/typeAliasWithNotNullBound.kt");
|
||||
|
||||
+5
@@ -634,6 +634,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticPropertiesWrongImplicitReceiver.kt")
|
||||
public void testSyntheticPropertiesWrongImplicitReceiver() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/syntheticPropertiesWrongImplicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasWithNotNullBound.kt")
|
||||
public void testTypeAliasWithNotNullBound() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/typeAliasWithNotNullBound.kt");
|
||||
|
||||
+3
-3
@@ -26,9 +26,9 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope
|
||||
import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeNullability
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.fir.types.withNullability
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
@@ -117,11 +117,11 @@ class MemberScopeTowerLevel(
|
||||
}
|
||||
}
|
||||
|
||||
if (!forInnerConstructorDelegationCalls) {
|
||||
if (!forInnerConstructorDelegationCalls && extensionReceiver == null) {
|
||||
val withSynthetic = FirSyntheticPropertiesScope(session, scope)
|
||||
withSynthetic.processScopeMembers { symbol ->
|
||||
empty = false
|
||||
output.consumeCandidate(symbol, NotNullableReceiverValue(dispatchReceiver), extensionReceiver as? ImplicitReceiverValue<*>)
|
||||
output.consumeCandidate(symbol, NotNullableReceiverValue(dispatchReceiver), null)
|
||||
}
|
||||
}
|
||||
return if (empty) ProcessorAction.NONE else ProcessorAction.NEXT
|
||||
|
||||
Reference in New Issue
Block a user