diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-05 18:21:20 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | d96cb84c35bfe47718850c1b8db435e67d512a0e (patch) | |
tree | e03607f60dfdbb5e66ef50f4a2e47cc26d8cb667 /tests/run | |
parent | 60b6c6a3059b23cf0cc1968cc3c7ee3886784721 (diff) | |
download | dotty-d96cb84c35bfe47718850c1b8db435e67d512a0e.tar.gz dotty-d96cb84c35bfe47718850c1b8db435e67d512a0e.tar.bz2 dotty-d96cb84c35bfe47718850c1b8db435e67d512a0e.zip |
Test case for closure inlining
This test works, but closures are not currently inlined.
That's a still to do.
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/inlinedAssign.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/run/inlinedAssign.scala b/tests/run/inlinedAssign.scala new file mode 100644 index 000000000..735158209 --- /dev/null +++ b/tests/run/inlinedAssign.scala @@ -0,0 +1,18 @@ +object Test { + + @dotty.annotation.inline + def swap[T](x: T, x_= : T => Unit, y: T, y_= : T => Unit) = { + val t = x + x_=(y) + y_=(t) + } + + def main(args: Array[String]) = { + var x = 1 + var y = 2 + @dotty.annotation.inline def setX(z: Int) = x = z + @dotty.annotation.inline def setY(z: Int) = y = z + swap[Int](x, setX, y, setY) + assert(x == 2 && y == 1) + } +} |