FIR: Run callable references resolution for synthetic-select calls

This commit is contained in:
Denis Zharkov
2020-02-11 13:16:27 +03:00
parent 003aea2e68
commit 5a2cdfcab4
15 changed files with 82 additions and 45 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun baz(i: Int) = i
fun <T> bar(x: T): T = x
@@ -27,4 +26,4 @@ fun box(): String {
if ((if (true) ::baz else ::baz)(1) != 1) return "fail 6"
return "OK"
}
}
@@ -7,11 +7,11 @@ fun test() {
val a = if (true) {
val x = 1
"".length
<!UNRESOLVED_REFERENCE!>::foo<!>
::foo
} else {
<!UNRESOLVED_REFERENCE!>::foo<!>
::foo
}
a checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction0<Int>>() }
}
fun foo(): Int = 0
fun foo(): Int = 0
@@ -6,18 +6,18 @@ fun <T> bar(x: T): T = TODO()
fun nullableFun(): ((Int) -> Int)? = null
fun test() {
val x1: (Int) -> Int = bar(if (true) <!UNRESOLVED_REFERENCE!>::baz<!> else <!UNRESOLVED_REFERENCE!>::baz<!>)
val x2: (Int) -> Int = bar(nullableFun() ?: <!UNRESOLVED_REFERENCE!>::baz<!>)
val x3: (Int) -> Int = bar(::baz ?: <!UNRESOLVED_REFERENCE!>::baz<!>)
val x1: (Int) -> Int = bar(if (true) ::baz else ::baz)
val x2: (Int) -> Int = bar(nullableFun() ?: ::baz)
val x3: (Int) -> Int = bar(::baz ?: ::baz)
val i = 0
val x4: (Int) -> Int = bar(when (i) {
10 -> <!UNRESOLVED_REFERENCE!>::baz<!>
20 -> <!UNRESOLVED_REFERENCE!>::baz<!>
else -> <!UNRESOLVED_REFERENCE!>::baz<!>
10 -> ::baz
20 -> ::baz
else -> ::baz
})
val x5: (Int) -> Int = bar(<!UNRESOLVED_REFERENCE!>::baz<!>!!)
val x5: (Int) -> Int = bar(::baz!!)
<!UNRESOLVED_REFERENCE!>(if (true) <!UNRESOLVED_REFERENCE!>::baz<!> else <!UNRESOLVED_REFERENCE!>::baz<!>)(1)<!>
}
(if (true) ::baz else ::baz)(1)
}
@@ -2,10 +2,10 @@
fun test() {
data class Pair<F, S>(val first: F, val second: S)
val (x, y) =
Pair(1,
val (<!UNRESOLVED_REFERENCE!>x<!>, <!UNRESOLVED_REFERENCE!>y<!>) =
<!INAPPLICABLE_CANDIDATE!>Pair<!>(1,
if (1 == 1)
<!UNRESOLVED_REFERENCE!>Pair<String, String>::first<!>
Pair<String, String>::first
else
<!UNRESOLVED_REFERENCE!>Pair<String, String>::second<!>)
}
Pair<String, String>::second)
}
@@ -18,8 +18,8 @@ class Foo(val a: String, val b: String)
fun test2() {
val prop : Foo.() -> String = if (true) {
<!UNRESOLVED_REFERENCE!>Foo::a<!>
Foo::a
} else {
<!UNRESOLVED_REFERENCE!>Foo::b<!>
Foo::b
}
}
@@ -4,33 +4,33 @@
fun testWhen(x: Any?) {
val y = when (x) {
null -> ""
else -> <!UNRESOLVED_REFERENCE!>::unresolved<!>
else -> ::unresolved
}
}
fun testWhenWithBraces(x: Any?) {
val z = when(x) {
null -> { "" }
else -> { <!UNRESOLVED_REFERENCE!>::unresolved<!> }
else -> { ::unresolved }
}
}
fun testIf(x: Any?) {
val y = if (x != null) <!UNRESOLVED_REFERENCE!>::unresolved<!> else null
val y = if (x != null) ::unresolved else null
}
fun testIfWithBraces(x: Any?) {
val z = if (x != null) { <!UNRESOLVED_REFERENCE!>::unresolved<!> } else { null }
val z = if (x != null) { ::unresolved } else { null }
}
fun testElvis(x: Any?) {
val y = x ?: <!UNRESOLVED_REFERENCE!>::unresolved<!>
val y = x ?: ::unresolved
}
fun testExclExcl() {
val y = <!UNRESOLVED_REFERENCE!>:: unresolved<!>!!
val y = :: unresolved!!
}
fun testTry() {
val v = try { <!UNRESOLVED_REFERENCE!>::unresolved<!> } catch (e: Exception) {}
val v = try { ::unresolved } catch (e: Exception) {}
}