mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-18 08:31:38 +00:00
Type of '::foo' for a function foo in a class A should be KFunction0<Unit>, not KFunction1<A, Unit>. Continue to report an error in this case, to be maybe supported in the future
25 lines
673 B
Kotlin
Vendored
25 lines
673 B
Kotlin
Vendored
// !CHECK_TYPE
|
|
|
|
import kotlin.reflect.KFunction0
|
|
|
|
fun explicitlyExpectFunction0(f: () -> Unit) = f
|
|
fun explicitlyExpectFunction1(f: (A) -> Unit) = f
|
|
|
|
fun foo() {}
|
|
|
|
class A {
|
|
fun foo() {}
|
|
|
|
fun main() {
|
|
val x = ::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>foo<!>
|
|
|
|
checkSubtype<KFunction0<Unit>>(x)
|
|
|
|
explicitlyExpectFunction0(x)
|
|
explicitlyExpectFunction1(<!TYPE_MISMATCH!>x<!>)
|
|
|
|
explicitlyExpectFunction0(::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>foo<!>)
|
|
explicitlyExpectFunction1(<!TYPE_MISMATCH!>::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>foo<!><!>)
|
|
}
|
|
}
|