K2: Fix priority for implicit receiver + extensionInvoke
See K1 counterpart at org.jetbrains.kotlin.resolve.calls.tower.TowerResolver.Task.processImplicitReceiver ^KT-58943 Fixed ^KT-59541 Fixed
This commit is contained in:
committed by
Space Team
parent
1f120ecd20
commit
3279313f2c
+1
-1
@@ -14,7 +14,7 @@ FILE: invokePriority.kt
|
||||
|
||||
String(1).R|<local>/foo|()
|
||||
R|kotlin/with|<R|kotlin/String|, R|kotlin/Unit|>(String(2), <L> = with@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||
this@R|special/anonymous|.R|<local>/foo|()
|
||||
R|<local>/foo|.R|SubstitutionOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(this@R|special/anonymous|)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ class A {
|
||||
fun String.foo(): Unit {} // (2)
|
||||
"1".foo() // resolves to (2)
|
||||
with("2") {
|
||||
foo() // BUG: resolves to (1) in old FE, but to (2) in FIR
|
||||
foo() // resolves to (1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -18557,6 +18557,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/fir/linkViaSignatures.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localInvokeExtension.kt")
|
||||
public void testLocalInvokeExtension() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/localInvokeExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localOverrideWithDefaultInLocalOverridden.kt")
|
||||
public void testLocalOverrideWithDefaultInLocalOverridden() throws Exception {
|
||||
|
||||
+6
@@ -18557,6 +18557,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/fir/linkViaSignatures.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localInvokeExtension.kt")
|
||||
public void testLocalInvokeExtension() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/localInvokeExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localOverrideWithDefaultInLocalOverridden.kt")
|
||||
public void testLocalOverrideWithDefaultInLocalOverridden() throws Exception {
|
||||
|
||||
+1
@@ -431,6 +431,7 @@ private class InvokeFunctionResolveTask(
|
||||
val towerGroup =
|
||||
TowerGroup
|
||||
.Implicit(depth)
|
||||
// see invokeExtensionVsOther2.kt test
|
||||
.InvokeExtensionWithImplicitReceiver
|
||||
.withGivenInvokeReceiverGroup(InvokeResolvePriority.INVOKE_EXTENSION)
|
||||
|
||||
|
||||
+10
-6
@@ -37,13 +37,17 @@ sealed class TowerGroupKind(val index: Byte) : Comparable<TowerGroupKind> {
|
||||
|
||||
data object Member : TowerGroupKind(4)
|
||||
|
||||
class Local(depth: Int) : WithDepth(5, depth)
|
||||
// If a variable of extension function type belong to some scope X, and there's an implicit receiver Y, then its invoke candidate
|
||||
// should be less prioritized than the member scope of Y (see diagnostics/tests/resolve/priority/invokeExtensionVsOther2.kt),
|
||||
// but more prioritized than extensions in X with bound receiver of Y (see analysis-tests/testData/resolveWithStdlib/problems/invokePriority.kt).
|
||||
// That's why it's been places between Member and Local/ImplicitOrNonLocal.
|
||||
data object InvokeExtensionWithImplicitReceiver : TowerGroupKind(5)
|
||||
|
||||
class ImplicitOrNonLocal(depth: Int, val kindForDebugSake: String) : WithDepth(6, depth)
|
||||
class Local(depth: Int) : WithDepth(6, depth)
|
||||
|
||||
class ContextReceiverGroup(depth: Int) : WithDepth(7, depth)
|
||||
class ImplicitOrNonLocal(depth: Int, val kindForDebugSake: String) : WithDepth(7, depth)
|
||||
|
||||
data object InvokeExtensionWithImplicitReceiver : TowerGroupKind(8)
|
||||
class ContextReceiverGroup(depth: Int) : WithDepth(8, depth)
|
||||
|
||||
data object QualifierValue : TowerGroupKind(9)
|
||||
|
||||
@@ -198,6 +202,8 @@ private constructor(
|
||||
|
||||
val Member get() = kindOf(TowerGroupKind.Member)
|
||||
|
||||
val InvokeExtensionWithImplicitReceiver get() = kindOf(TowerGroupKind.InvokeExtensionWithImplicitReceiver)
|
||||
|
||||
fun Local(depth: Int) = kindOf(TowerGroupKind.Local(depth))
|
||||
|
||||
fun Implicit(depth: Int) = kindOf(TowerGroupKind.Implicit(depth))
|
||||
@@ -205,8 +211,6 @@ private constructor(
|
||||
|
||||
fun ContextReceiverGroup(depth: Int) = kindOf(TowerGroupKind.ContextReceiverGroup(depth))
|
||||
|
||||
val InvokeExtensionWithImplicitReceiver get() = kindOf(TowerGroupKind.InvokeExtensionWithImplicitReceiver)
|
||||
|
||||
fun TopPrioritized(depth: Int) = kindOf(TowerGroupKind.TopPrioritized(depth))
|
||||
|
||||
fun InvokeReceiver(
|
||||
|
||||
Reference in New Issue
Block a user