diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-02 13:52:28 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | 6f9f29e1f90c017f30a81b0e37f994b5b8cd8507 (patch) | |
tree | b4fc1f8c5146c242f9ccd35700286a613bb20e01 /tests/run | |
parent | b8a117634b636d6255e6233ae1996f6c7b90dcae (diff) | |
download | dotty-6f9f29e1f90c017f30a81b0e37f994b5b8cd8507.tar.gz dotty-6f9f29e1f90c017f30a81b0e37f994b5b8cd8507.tar.bz2 dotty-6f9f29e1f90c017f30a81b0e37f994b5b8cd8507.zip |
Recursive inlining tests
pos/power inlines with alomst no extraneous boilerplate.
neg/power gives an error that maximal numbers of inlines was exceeded.
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/power.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/run/power.scala b/tests/run/power.scala new file mode 100644 index 000000000..2bb66fa8d --- /dev/null +++ b/tests/run/power.scala @@ -0,0 +1,17 @@ +object Test { + + @dotty.annotation.inline + def power(x: Double, n: Int): Double = + if (n == 0) 1.0 + else if (n == 1) x + else { + val y = power(x, n / 2) + if (n % 2 == 0) y * y else y * y * x + } + + def main(args: Array[String]): Unit = { + println(power(2.0, 10)) + def x = 2.0 + println(power(x, 11)) + } +} |