Ignore resolution to function without arguments on LHS of '::'

In the expression "Runnable::run" we were resolving the left-hand side to the
SAM constructor of Runnable. Now we detect this situation, ignore the result of
such resolution, and continue resolving the LHS as a type
This commit is contained in:
Alexander Udalov
2016-05-27 19:34:23 +03:00
parent 04c190231a
commit 0ce6bd9999
8 changed files with 124 additions and 1 deletions
@@ -0,0 +1 @@
fun test() = ("").<!FUNCTION_CALL_EXPECTED!>hashCode<!>::hashCode
@@ -0,0 +1,3 @@
package
public fun test(): kotlin.reflect.KFunction0<kotlin.Int>
@@ -0,0 +1,16 @@
// FILE: Foo.kt
package test
class Foo {
fun bar() {}
}
// FILE: test.kt
import test.Foo
fun Foo(): String = ""
val f = Foo::bar
val g = Foo::<!UNRESOLVED_REFERENCE!>length<!>
@@ -0,0 +1,16 @@
package
public val f: kotlin.reflect.KFunction1<test.Foo, kotlin.Unit>
public val g: [ERROR : Type for Foo::length]
public fun Foo(): kotlin.String
package test {
public final class Foo {
public constructor Foo()
public final fun bar(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -0,0 +1,31 @@
// FILE: test/GenericSam.java
package test;
public interface GenericSam<T> {
void invoke(T t);
}
// FILE: test.kt
import test.GenericSam
fun f1() = Runnable::class
fun f2() = Runnable::run
fun f3() = java.lang.Runnable::class
fun f4() = java.lang.Runnable::run
fun f5() = GenericSam::class
fun f6() = GenericSam<*>::invoke
fun f7() = test.GenericSam::class
fun f8() = test.GenericSam<String>::invoke
fun g1() = Runnable {}::class
fun g2() = Runnable {}::run
fun g3() = java.lang.Runnable {}::class
fun g4() = java.lang.Runnable {}::run
fun g5() = GenericSam<String> {}::class
fun g6() = GenericSam<String> {}::invoke
fun g7() = test.GenericSam<String> {}::class
fun g8() = test.GenericSam<String> {}::invoke
@@ -0,0 +1,18 @@
package
public fun f1(): kotlin.reflect.KClass<java.lang.Runnable>
public fun f2(): kotlin.reflect.KFunction1<java.lang.Runnable, kotlin.Unit>
public fun f3(): kotlin.reflect.KClass<java.lang.Runnable>
public fun f4(): kotlin.reflect.KFunction1<java.lang.Runnable, kotlin.Unit>
public fun f5(): kotlin.reflect.KClass<test.GenericSam<*>>
public fun f6(): kotlin.reflect.KFunction2<test.GenericSam<*>, kotlin.Nothing!, kotlin.Unit>
public fun f7(): kotlin.reflect.KClass<test.GenericSam<*>>
public fun f8(): kotlin.reflect.KFunction2<test.GenericSam<kotlin.String>, kotlin.String!, kotlin.Unit>
public fun g1(): kotlin.reflect.KClass<java.lang.Runnable>
public fun g2(): kotlin.reflect.KFunction0<kotlin.Unit>
public fun g3(): kotlin.reflect.KClass<java.lang.Runnable>
public fun g4(): kotlin.reflect.KFunction0<kotlin.Unit>
public fun g5(): kotlin.reflect.KClass<test.GenericSam<kotlin.String>>
public fun g6(): kotlin.reflect.KFunction1<kotlin.String!, kotlin.Unit>
public fun g7(): kotlin.reflect.KClass<test.GenericSam<kotlin.String>>
public fun g8(): kotlin.reflect.KFunction1<kotlin.String!, kotlin.Unit>