Files
kotlin-fork/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.fir.kt
T
Kirill Rakhman d91000e39c [FIR] Report INAPPLICABLE_CANDIDATE or more specific diagnostic for callable references
... instead of just UNRESOLVED_REFERENCE when something went wrong
during resolution.

#KT-59401 related
2023-11-08 15:45:48 +00:00

32 lines
854 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(::<!INAPPLICABLE_CANDIDATE!>foo<!>)
expectFunction1String(::<!INAPPLICABLE_CANDIDATE!>foo<!>)
}
}