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:
Denis Zharkov
2020-01-14 18:50:17 +03:00
parent 4ff8acf5d7
commit c48539feb3
8 changed files with 80 additions and 2 deletions
@@ -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
@@ -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
@@ -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