NI: Fix callable references resolution when LHS is generic nested class
In case of null qualifier, we should not look into any static scope NB: factory::createCallableProcessor returns NoExplicitReceiver processor in case of null-receiver, that makes resolving the call in the test as `property(::key)` that matches to the property itself, thus leading to overload resolution ambiguity ^KT-35887 Fixed
This commit is contained in:
Generated
+10
@@ -2628,6 +2628,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt");
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35887.kt")
|
||||||
|
public void testKt35887() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35887_simple.kt")
|
||||||
|
public void testKt35887_simple() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt8596.kt")
|
@TestMetadata("kt8596.kt")
|
||||||
public void testKt8596() throws Exception {
|
public void testKt8596() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt");
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt");
|
||||||
|
|||||||
+6
-2
@@ -85,11 +85,15 @@ fun createCallableReferenceProcessor(factory: CallableReferencesCandidateFactory
|
|||||||
return factory.createCallableProcessor(explicitReceiver)
|
return factory.createCallableProcessor(explicitReceiver)
|
||||||
}
|
}
|
||||||
is LHSResult.Type -> {
|
is LHSResult.Type -> {
|
||||||
val static = factory.createCallableProcessor(lhsResult.qualifier)
|
val static = lhsResult.qualifier?.let(factory::createCallableProcessor)
|
||||||
val unbound = factory.createCallableProcessor(lhsResult.unboundDetailedReceiver)
|
val unbound = factory.createCallableProcessor(lhsResult.unboundDetailedReceiver)
|
||||||
|
|
||||||
// note that if we use PrioritizedCompositeScopeTowerProcessor then static will win over unbound members
|
// note that if we use PrioritizedCompositeScopeTowerProcessor then static will win over unbound members
|
||||||
val staticOrUnbound = SamePriorityCompositeScopeTowerProcessor(static, unbound)
|
val staticOrUnbound =
|
||||||
|
if (static != null)
|
||||||
|
SamePriorityCompositeScopeTowerProcessor(static, unbound)
|
||||||
|
else
|
||||||
|
unbound
|
||||||
|
|
||||||
val asValue = lhsResult.qualifier?.classValueReceiverWithSmartCastInfo ?: return staticOrUnbound
|
val asValue = lhsResult.qualifier?.classValueReceiverWithSmartCastInfo ?: return staticOrUnbound
|
||||||
return PrioritizedCompositeScopeTowerProcessor(staticOrUnbound, factory.createCallableProcessor(asValue))
|
return PrioritizedCompositeScopeTowerProcessor(staticOrUnbound, factory.createCallableProcessor(asValue))
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// SKIP_TXT
|
||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
import kotlin.reflect.KProperty0
|
||||||
|
import kotlin.reflect.KProperty1
|
||||||
|
|
||||||
|
object A
|
||||||
|
|
||||||
|
fun <T : Any, TProperty : Any?> property(property: KProperty1<T, TProperty>) = A
|
||||||
|
|
||||||
|
fun <TProperty> property(property: KProperty0<TProperty>) = A
|
||||||
|
|
||||||
|
val <K> K.key get() : A = property(Map.Entry<K, *>::key) // overload resolution ambiguity in the NI, OK in the OI
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// SKIP_TXT
|
||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
import kotlin.reflect.KProperty0
|
||||||
|
import kotlin.reflect.KProperty1
|
||||||
|
|
||||||
|
object A
|
||||||
|
|
||||||
|
fun <T : Any, TProperty : Any?> property(property: KProperty1<T, TProperty>) = A
|
||||||
|
|
||||||
|
fun <TProperty> property(property: KProperty0<TProperty>) = A
|
||||||
|
|
||||||
|
val <K> K.key get() : A = property(Map.Entry<K, *>::key) // overload resolution ambiguity in the NI, OK in the OI
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// SKIP_TXT
|
||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
import kotlin.reflect.KProperty0
|
||||||
|
|
||||||
|
object A
|
||||||
|
|
||||||
|
fun <TProperty> property0(property: KProperty0<TProperty>) = A
|
||||||
|
val <K> K.key get() : A = <!INAPPLICABLE_CANDIDATE!>property0<!>(Map.Entry<K, *>::key) // should be forbidden
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// SKIP_TXT
|
||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
import kotlin.reflect.KProperty0
|
||||||
|
|
||||||
|
object A
|
||||||
|
|
||||||
|
fun <TProperty> property0(property: KProperty0<TProperty>) = A
|
||||||
|
val <K> K.key get() : A = property0(<!TYPE_MISMATCH!>Map.Entry<K, *>::key<!>) // should be forbidden
|
||||||
@@ -2635,6 +2635,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt");
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35887.kt")
|
||||||
|
public void testKt35887() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35887_simple.kt")
|
||||||
|
public void testKt35887_simple() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt8596.kt")
|
@TestMetadata("kt8596.kt")
|
||||||
public void testKt8596() throws Exception {
|
public void testKt8596() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt");
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt");
|
||||||
|
|||||||
Generated
+10
@@ -2630,6 +2630,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt");
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35887.kt")
|
||||||
|
public void testKt35887() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35887_simple.kt")
|
||||||
|
public void testKt35887_simple() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt8596.kt")
|
@TestMetadata("kt8596.kt")
|
||||||
public void testKt8596() throws Exception {
|
public void testKt8596() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt");
|
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user