Resolve invoke on any kind of expressions, not only on simple name expressions

This commit is contained in:
Svetlana Isakova
2014-02-04 19:07:06 +04:00
parent c7087d170e
commit a829da185d
31 changed files with 391 additions and 101 deletions
@@ -0,0 +1,23 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
public class A {
public fun get(vararg attrs : Pair<String, String>) : A = this
}
fun String.plus() : A = A()
fun A.div(s : String) : A = A()
fun test() {
(+"node2" / "node3" / "zzz") ["attr" to "value", "a2" to "v2"]
}
//---------
class B {
public fun get(s : String, q : String) : B = this
public fun get(s : Pair<String, String>) : B = this
public fun invoke(q : B.() -> Unit) : B = this
}
val x = B()["a", "v"]["a" to "b"] {} ["q" to "p"] // does not parses around {}
//from library
data class Pair<out A, out B> (val first: A, val second: B)
fun <A,B> A.to(that: B) = Pair(this, that)
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun Int.invoke(i: Int, a: Any) {}
fun Int.invoke(a: Any, i: Int) {}
fun foo(i: Int) {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>i<!>(1, 1)
<!OVERLOAD_RESOLUTION_AMBIGUITY!>5<!>(1, 2)
}
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class My {
private fun Int.invoke(s: String) {}
}
fun My.foo(i: Int) {
<!INVISIBLE_MEMBER!>i<!>("")
<!INVISIBLE_MEMBER!>1<!>("")
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A<T>
fun <T> T.invoke(a: A<T>) {}
fun foo(s: String, ai: A<Int>) {
1(ai)
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>s<!>(ai)
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>""<!>(ai)
}
@@ -0,0 +1,4 @@
fun foo(i: Int) {
<!FUNCTION_EXPECTED!>i<!>()
<!CALLEE_NOT_A_FUNCTION!>1<!>()
}
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun String.invoke(i: Int) {}
fun foo(s: String?) {
<!UNSAFE_CALL!>s<!>(1)
<!UNSAFE_CALL!>(s ?: null)<!>(1)
}
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun String.invoke(i: Int) {}
fun foo(i: Int) {
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>i<!>(1)
<!CALLEE_NOT_A_FUNCTION!>1<!>(1)
}