Support for property reference inlining
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Foo(val a: String)
|
||||
|
||||
inline fun test(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(Foo("OK")::a)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
object Foo {
|
||||
val a: String = "OK"
|
||||
}
|
||||
|
||||
inline fun test(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(Foo::a)
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
object Foo {
|
||||
val a: String = "OK"
|
||||
}
|
||||
|
||||
inline fun test(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.Foo.a
|
||||
import test.test
|
||||
|
||||
fun box(): String {
|
||||
return test(::a)
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Foo(val z: String)
|
||||
|
||||
val Foo.a: String
|
||||
get() = z
|
||||
|
||||
inline fun test(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(Foo("OK")::a)
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package test
|
||||
|
||||
inline fun call(a: String, b: String, s: String.(String) -> String): Int {
|
||||
inline fun call(a: String, b: String, s: String.(String) -> String): String {
|
||||
return a.s(b)
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ inline fun call(a: String, b: String, s: String.(String) -> String): Int {
|
||||
import test.*
|
||||
|
||||
fun box() : String {
|
||||
return return call("O", "K", String::plus)
|
||||
return call("O", "K", String::plus)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun call(p: String, s: String.() -> Int): Int {
|
||||
return p.s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box() : String {
|
||||
return if (call("123", String::length) == 3) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Foo(val a: String)
|
||||
|
||||
inline fun <T> test(receiver: T, selector: (T) -> String): String {
|
||||
return selector(receiver)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(Foo("OK"), Foo::a)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
val a: String
|
||||
get() = "OK"
|
||||
|
||||
inline fun test(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(::a)
|
||||
}
|
||||
Reference in New Issue
Block a user