Support bound references to objects and companion objects
Tweak member extension detection a little bit to prohibit extensions imported from objects (they don't have one of the receiver parameters)
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
fun foo(): String = "companion"
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun foo(): Int = 0
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val r1 = C::foo
|
||||
checkSubtype<(C) -> Int>(r1)
|
||||
|
||||
val r2 = test.C::foo
|
||||
checkSubtype<(C) -> Int>(r2)
|
||||
|
||||
val r3 = C.Companion::foo
|
||||
checkSubtype<() -> String>(r3)
|
||||
|
||||
val r4 = test.C.Companion::foo
|
||||
checkSubtype<() -> String>(r4)
|
||||
|
||||
val r5 = (C)::foo
|
||||
checkSubtype<() -> String>(r5)
|
||||
|
||||
val r6 = (test.C)::foo
|
||||
checkSubtype<() -> String>(r6)
|
||||
|
||||
val c = C.Companion
|
||||
val r7 = c::foo
|
||||
checkSubtype<() -> String>(r7)
|
||||
|
||||
C::<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package
|
||||
|
||||
package test {
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
object Obj {
|
||||
fun foo() {}
|
||||
val bar = 2
|
||||
}
|
||||
|
||||
fun test() {
|
||||
checkSubtype<() -> Unit>(Obj::foo)
|
||||
checkSubtype<() -> Int>(Obj::bar)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public object Obj {
|
||||
private constructor Obj()
|
||||
public final val bar: kotlin.Int = 2
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user