Reference --> lambda supports bound references now #KT-16292 Fixed

This commit is contained in:
Mikhail Glukhikh
2017-03-10 16:38:35 +03:00
parent f6734e74e1
commit 831467891c
14 changed files with 106 additions and 14 deletions
@@ -1,5 +1,5 @@
// IS_APPLICABLE: false
// IS_APPLICABLE: true
val x = 1
// Not supported yet
val y = <caret>x::hashCode
@@ -0,0 +1,5 @@
// IS_APPLICABLE: true
val x = 1
val y = { x.hashCode() }
@@ -0,0 +1,9 @@
// WITH_RUNTIME
val list = listOf(1, 2, 3).map(<caret>Utils.Companion::foo)
class Utils {
companion object {
fun foo(x: Int) = x
}
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
val list = listOf(1, 2, 3).map { Utils.foo(it) }
class Utils {
companion object {
fun foo(x: Int) = x
}
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: true
// WITH_RUNTIME
fun foo() {
listOf(1).forEach { (-it).let(<caret>it::bar) }
}
fun Int.bar(arg: Int) {
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: true
// WITH_RUNTIME
fun foo() {
listOf(1).forEach { (-it).let { arg -> it.bar(arg) } }
}
fun Int.bar(arg: Int) {
}
@@ -0,0 +1,4 @@
class Owner(val z: Int) {
fun foo(y: Int) = y + z
val x = <caret>this::foo
}
@@ -0,0 +1,4 @@
class Owner(val z: Int) {
fun foo(y: Int) = y + z
val x = { y: Int -> this.foo(y) }
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: true
// WITH_RUNTIME
fun foo() {
listOf(1).forEach { run(<caret>it::bar) }
}
fun Int.bar() {
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: true
// WITH_RUNTIME
fun foo() {
listOf(1).forEach { run { it.bar() } }
}
fun Int.bar() {
}
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// IS_APPLICABLE: true
// WITH_RUNTIME
val list = listOf(1, 2, 3).map(<caret>Utils::foo)
@@ -0,0 +1,7 @@
// IS_APPLICABLE: true
// WITH_RUNTIME
val list = listOf(1, 2, 3).map { Utils.foo(it) }
object Utils {
fun foo(x: Int) = x
}