Support "::foo" as a short-hand for "this::foo"

#KT-15667 Fixed
This commit is contained in:
Alexander Udalov
2017-08-24 17:15:42 +03:00
parent d2ff821a3b
commit 2877314313
24 changed files with 195 additions and 116 deletions
@@ -1,24 +1,31 @@
// !CHECK_TYPE
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
import kotlin.reflect.KFunction0
fun explicitlyExpectFunction0(f: () -> Unit) = f
fun explicitlyExpectFunction1(f: (A) -> Unit) = f
fun expectFunction0Unit(f: () -> Unit) = f
fun expectFunction0String(f: () -> String) = f
fun expectFunction1Unit(f: (A) -> Unit) = f
fun expectFunction1String(f: (A) -> String) = f
fun foo() {}
fun foo(): String = ""
class A {
fun foo() {}
fun main() {
val x = ::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>foo<!>
val x = ::foo
checkSubtype<KFunction0<Unit>>(x)
explicitlyExpectFunction0(x)
explicitlyExpectFunction1(<!TYPE_MISMATCH!>x<!>)
expectFunction0Unit(x)
expectFunction0String(<!TYPE_MISMATCH!>x<!>)
expectFunction1Unit(<!TYPE_MISMATCH!>x<!>)
expectFunction1String(<!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<!><!>)
expectFunction0Unit(::foo)
expectFunction0String(::foo)
expectFunction1Unit(<!TYPE_MISMATCH!>::foo<!>)
expectFunction1String(<!TYPE_MISMATCH!>::foo<!>)
}
}