Files
kotlin-fork/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.fir.kt
T
Kirill Rakhman 2f3293f99e [FIR] Skip redundant INAPPLICABLE_CANDIDATE on call with unresolved callable reference argument
A new resolution diagnostic UnsuccessfulCallableReferenceAtom is
introduced that is used in EagerResolveOfCallableReferences.
No diagnostic is reported on unresolved calls with this diagnostic
because

#KT-59856
2023-07-20 07:29:18 +00:00

32 lines
850 B
Kotlin
Vendored

// !CHECK_TYPE
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
import kotlin.reflect.KFunction0
fun expectFunction0Unit(f: () -> Unit) = f
fun expectFunction0String(f: () -> String) = f
fun expectFunction1Unit(f: (A) -> Unit) = f
fun expectFunction1String(f: (A) -> String) = f
fun foo(): String = ""
class A {
fun foo() {}
fun main() {
val x = ::foo
checkSubtype<KFunction0<Unit>>(x)
expectFunction0Unit(x)
expectFunction0String(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
expectFunction1Unit(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
expectFunction1String(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
expectFunction0Unit(::foo)
expectFunction0String(::foo)
expectFunction1Unit(::<!UNRESOLVED_REFERENCE!>foo<!>)
expectFunction1String(::<!UNRESOLVED_REFERENCE!>foo<!>)
}
}