提交 5ab05e6e 编写于 作者: D Denis Zharkov

FIR: Fix incorrect resolution to synthetic property by implicit receiver

When there's an explicit one

^KT-39028 Fixed
上级 293f78ef
// !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>() }
}
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| {
}
......@@ -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");
......
......@@ -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");
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册