aboutsummaryrefslogtreecommitdiff
path: root/tests/run/inlinePrivates.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-10 12:15:22 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-02 16:11:21 +0200
commit8e66f5384837ba662eb6243e221e18e7364757ee (patch)
tree10ccdf224d7982407f5bbeda991f704848fee15b /tests/run/inlinePrivates.scala
parent6bf7768e4e2e604f93f27efacf28d076d97ac951 (diff)
downloaddotty-8e66f5384837ba662eb6243e221e18e7364757ee.tar.gz
dotty-8e66f5384837ba662eb6243e221e18e7364757ee.tar.bz2
dotty-8e66f5384837ba662eb6243e221e18e7364757ee.zip
More inline tests
Diffstat (limited to 'tests/run/inlinePrivates.scala')
-rw-r--r--tests/run/inlinePrivates.scala54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/run/inlinePrivates.scala b/tests/run/inlinePrivates.scala
new file mode 100644
index 000000000..ade4592df
--- /dev/null
+++ b/tests/run/inlinePrivates.scala
@@ -0,0 +1,54 @@
+object Test {
+
+ class C[T](private val x: T) {
+
+ private def foo[Z](z: Z): T = x
+
+ private var y: T = _
+
+ @inline def get1 = x
+ @inline def get2[U](c: C[U]) = c.x
+
+ @inline def foo1(x: Int) = foo(x)
+ @inline def foo2[U](c: C[U]) = c.foo(x)
+
+ @inline def set1(z: T) = { y = z; y }
+ @inline def set2[U](c: C[U]) = { c.y = c.x; c.y }
+ }
+
+ object CC {
+ private val x = 3
+ @inline def get1 = x
+ }
+
+ def main(args: Array[String]) = {
+ val cc = new C(2)
+ assert(cc.get1 == 2)
+ assert(cc.get2(cc) == 2)
+ assert(cc.foo1(1) == 2)
+ assert(cc.foo2(cc) == 2)
+ assert(cc.set1(3) == 3)
+ assert(cc.set2(cc) == 2)
+object Test {
+
+ @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
+ @inline def setX(z: Int) = x = z
+ @inline def setY(z: Int) = y = z
+ swap[Int](x, setX, y, setY)
+ assert(x == 2 && y == 1)
+ }
+}
+
+ assert(CC.get1 == 3)
+ }
+
+}