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,12 +1,14 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
import kotlin.reflect.KFunction1
class A {
inner class Inner
fun main() {
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>Inner<!>
::Inner
val y = A::Inner
checkSubtype<KFunction1<A, Inner>>(y)
@@ -1,5 +1,7 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
import kotlin.reflect.KFunction1
class A {
@@ -7,7 +9,7 @@ class A {
}
fun A.main() {
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>Inner<!>
::Inner
val y = A::Inner
checkSubtype<KFunction1<A, A.Inner>>(y)
@@ -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<!>)
}
}
@@ -1,8 +1,10 @@
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 fun expectFunction0String(/*0*/ f: () -> kotlin.String): () -> kotlin.String
public fun expectFunction0Unit(/*0*/ f: () -> kotlin.Unit): () -> kotlin.Unit
public fun expectFunction1String(/*0*/ f: (A) -> kotlin.String): (A) -> kotlin.String
public fun expectFunction1Unit(/*0*/ f: (A) -> kotlin.Unit): (A) -> kotlin.Unit
public fun foo(): kotlin.String
public final class A {
public constructor A()