Properly process primitive receiver on inlining bound callable references
#KT-18728 Fixed
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user