Fix type of member references without explicit class on LHS

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
This commit is contained in:
Alexander Udalov
2016-04-11 13:29:11 +03:00
parent d8263eb0b8
commit 76d3246514
5 changed files with 38 additions and 33 deletions
@@ -1,6 +1,9 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction1
import kotlin.reflect.KFunction0
fun explicitlyExpectFunction0(f: () -> Unit) = f
fun explicitlyExpectFunction1(f: (A) -> Unit) = f
fun foo() {}
@@ -10,6 +13,12 @@ class A {
fun main() {
val x = ::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>foo<!>
checkSubtype<KFunction1<A, Unit>>(x)
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<!><!>)
}
}
@@ -1,5 +1,7 @@
package
public fun explicitlyExpectFunction0(/*0*/ f: () -> kotlin.Unit): () -> kotlin.Unit
public fun explicitlyExpectFunction1(/*0*/ f: (A) -> kotlin.Unit): (A) -> kotlin.Unit
public fun foo(): kotlin.Unit
public final class A {