Inline refactoring: more templates for captured fields

Support of complex lambda inlining cases
This commit is contained in:
Mikhael Bogdanov
2014-03-10 14:24:31 +04:00
parent 4a8bcc614a
commit 2dcc0bce46
23 changed files with 906 additions and 268 deletions
+19 -1
View File
@@ -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()}()