Inline refactoring: more templates for captured fields
Support of complex lambda inlining cases
This commit is contained in:
@@ -6,7 +6,22 @@ fun Data.test1(d: Data) : Long {
|
||||
with(input) {
|
||||
result = use<Long>{
|
||||
val output = Output(d)
|
||||
useNoInline<Long>{
|
||||
use<Long>{
|
||||
data()
|
||||
copyTo(output, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun Data.test2(d: Data) : Long {
|
||||
val input = Input(this)
|
||||
var result = 10.toLong()
|
||||
with2(input) {
|
||||
result = use<Long>{
|
||||
val output = Output(d)
|
||||
useNoInline<Long>{
|
||||
data()
|
||||
copyTo(output, 10)
|
||||
}
|
||||
@@ -21,5 +36,8 @@ fun box(): String {
|
||||
val result = Data().test1(Data())
|
||||
if (result != 100.toLong()) return "test1: ${result}"
|
||||
|
||||
val result2 = Data().test2(Data())
|
||||
if (result2 != 100.toLong()) return "test2: ${result2}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -25,3 +25,6 @@ public fun <R> useNoInline(block: ()-> R) : R {
|
||||
public fun Input.copyTo(output: Output, size: Int): Long {
|
||||
return output.doOutput(this.data()).toLong()
|
||||
}
|
||||
|
||||
|
||||
public inline fun with2<T>(receiver : T, body : T.() -> Unit) : Unit = {receiver.body()}()
|
||||
|
||||
Reference in New Issue
Block a user