diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-02 17:23:54 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | 96d057364703a9b89ca49f2ac16f2cdb140d396d (patch) | |
tree | e597ebb61fc730c3c1ba6c08fd027f7712adecb1 /tests | |
parent | a47a8008023ea04ff7f8d708567fb6a2c516caaa (diff) | |
download | dotty-96d057364703a9b89ca49f2ac16f2cdb140d396d.tar.gz dotty-96d057364703a9b89ca49f2ac16f2cdb140d396d.tar.bz2 dotty-96d057364703a9b89ca49f2ac16f2cdb140d396d.zip |
Support separate compilation
Inline trees can now be read form TASTY. However, positions are not set
correctly. This remains to be implemented.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run/inline/Test_2.scala | 18 | ||||
-rw-r--r-- | tests/run/inline/inlines_1.scala (renamed from tests/run/inlineTest.scala) | 17 | ||||
-rw-r--r-- | tests/run/inlinePower/Test_2.scala | 9 | ||||
-rw-r--r-- | tests/run/inlinePower/power_1.scala | 13 |
4 files changed, 42 insertions, 15 deletions
diff --git a/tests/run/inline/Test_2.scala b/tests/run/inline/Test_2.scala new file mode 100644 index 000000000..0d1723018 --- /dev/null +++ b/tests/run/inline/Test_2.scala @@ -0,0 +1,18 @@ +object Test { + + import p.inlines._ + + def main(args: Array[String]): Unit = { + println(f(10)) + println(f(f(10))) + + track("hello") { println("") } + + val o = new Outer + val i = new o.Inner + println(i.m) + //println(i.g) + //println(i.h) + } + +} diff --git a/tests/run/inlineTest.scala b/tests/run/inline/inlines_1.scala index 39153951e..64adb031c 100644 --- a/tests/run/inlineTest.scala +++ b/tests/run/inline/inlines_1.scala @@ -1,6 +1,7 @@ +package p import collection.mutable -object Test { +object inlines { final val monitored = false @@ -38,18 +39,4 @@ object Test { @dotty.annotation.inline def h = f ++ m } } - - def main(args: Array[String]): Unit = { - println(f(10)) - println(f(f(10))) - - track("hello") { println("") } - - val o = new Outer - val i = new o.Inner - println(i.m) - //println(i.g) - //println(i.h) - } - } diff --git a/tests/run/inlinePower/Test_2.scala b/tests/run/inlinePower/Test_2.scala new file mode 100644 index 000000000..8e16587b5 --- /dev/null +++ b/tests/run/inlinePower/Test_2.scala @@ -0,0 +1,9 @@ +import p.pow.power +object Test { + + def main(args: Array[String]): Unit = { + println(power(2.0, 10)) + def x = 2.0 + println(power(x, 11)) + } +} diff --git a/tests/run/inlinePower/power_1.scala b/tests/run/inlinePower/power_1.scala new file mode 100644 index 000000000..1faa10516 --- /dev/null +++ b/tests/run/inlinePower/power_1.scala @@ -0,0 +1,13 @@ +package p + +object pow { + + @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 + } +} |