Properly process primitive receiver on inlining bound callable references

#KT-18728 Fixed
This commit is contained in:
Mikhael Bogdanov
2017-06-30 13:11:53 +02:00
parent fe17c4416e
commit 49252f6eec
17 changed files with 404 additions and 5 deletions
@@ -0,0 +1,16 @@
// FILE: 1.kt
package test
inline fun <T, R> T.map(transform: (T) -> R): R {
return transform(this)
}
// FILE: 2.kt
import test.*
fun box(): String {
val result = 1.map(2::plus)
return if (result == 3) "OK" else "fail $result"
}
@@ -0,0 +1,16 @@
// FILE: 1.kt
package test
inline fun <T, R> T.map(transform: (T) -> R): R {
return transform(this)
}
// FILE: 2.kt
import test.*
fun box(): String {
val result = 1.map(3L::plus)
return if (result == 4L) "OK" else "fail $result"
}
@@ -0,0 +1,19 @@
// FILE: 1.kt
package test
inline fun <R> map(transform: () -> R): R {
return transform()
}
// FILE: 2.kt
import test.*
val Int.myInc
get() = this + 1
fun box(): String {
val result = map(2::myInc)
return if (result == 3) "OK" else "fail $result"
}
@@ -0,0 +1,18 @@
// FILE: 1.kt
package test
inline fun <R> map(transform: () -> R): R {
return transform()
}
// FILE: 2.kt
import test.*
val Long.myInc
get() = this + 1
fun box(): String {
val result = map(2L::myInc)
return if (result == 3L) "OK" else "fail $result"
}