[BE JVM] KT-51271 Set proper indices generating contextual inline call
[Tests] Test inline call with context receivers and default params
This commit is contained in:
committed by
teamcity
parent
dc210fa6ef
commit
4b366ddcf6
+55
@@ -0,0 +1,55 @@
|
||||
class Context {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
fun c(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline fun testInline(<this>: Context): Int {
|
||||
return <this>.c()
|
||||
}
|
||||
|
||||
inline fun testInlineWithArg(<this>: Context, i: Int): Int {
|
||||
return i.plus(other = <this>.c())
|
||||
}
|
||||
|
||||
inline fun Int.testInlineWithExtensionAndArg(<this>: Context, i: Int): Int {
|
||||
return <this>.plus(other = i).plus(other = <this>.c())
|
||||
}
|
||||
|
||||
inline fun Int.testInlineWithExtensionAndMultipleArgs(<this>: Context, i1: Int, i2: Int): Int {
|
||||
return <this>.plus(other = i1).plus(other = i2).plus(other = <this>.c())
|
||||
}
|
||||
|
||||
inline fun Int.testInlineWithExtensionAndMultipleContextsAndArgs(<this>: Context, <this>: Any, i1: Int = 1, i2: Int = 2): Int {
|
||||
return <this>.plus(other = i1).plus(other = i2).plus(other = <this>.c()).plus(other = when {
|
||||
EQEQ(arg0 = <this>, arg1 = null) -> 0
|
||||
else -> 1
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return with<Context, Nothing>(receiver = Context(), block = local fun Context.<anonymous>(): Nothing {
|
||||
var result: Int = 0
|
||||
result = result.plus(other = testInline(<this> = $this$with))
|
||||
result = result.plus(other = testInlineWithArg(<this> = $this$with, i = 1))
|
||||
result = result.plus(other = 1.testInlineWithExtensionAndArg(<this> = $this$with, i = 1))
|
||||
result = result.plus(other = 1.testInlineWithExtensionAndMultipleArgs(<this> = $this$with, i1 = 1, i2 = 2))
|
||||
with<Int, Unit>(receiver = 1, block = local fun Int.<anonymous>() {
|
||||
result = result.plus(other = 1.testInlineWithExtensionAndMultipleContextsAndArgs(<this> = $this$with, <this> = $this$with, i1 = 1, i2 = 2))
|
||||
result = result.plus(other = 1.testInlineWithExtensionAndMultipleContextsAndArgs(<this> = $this$with, <this> = $this$with))
|
||||
}
|
||||
)
|
||||
return when {
|
||||
EQEQ(arg0 = result, arg1 = 23) -> "OK"
|
||||
else -> "fail"
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user