aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/scala2traits
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-06-01 15:34:19 +0200
committerMartin Odersky <odersky@gmail.com>2015-06-01 15:35:21 +0200
commit5aaa40607f65d0f3c1af121df226d715c0d02673 (patch)
tree55a0aac003029893248e6b1eee830015df0d7a80 /tests/pos/scala2traits
parent9e56405ee979831cdccef6ed26dbe445c6808877 (diff)
downloaddotty-5aaa40607f65d0f3c1af121df226d715c0d02673.tar.gz
dotty-5aaa40607f65d0f3c1af121df226d715c0d02673.tar.bz2
dotty-5aaa40607f65d0f3c1af121df226d715c0d02673.zip
Add test case.
We are still lacking the setup to do this right for mixed Scala 2/Dotty runtime tests. So I checked into `pos` for now.
Diffstat (limited to 'tests/pos/scala2traits')
-rw-r--r--tests/pos/scala2traits/dotty-subclass.scala27
-rw-r--r--tests/pos/scala2traits/scala-trait.scala31
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/pos/scala2traits/dotty-subclass.scala b/tests/pos/scala2traits/dotty-subclass.scala
new file mode 100644
index 000000000..4e162dd14
--- /dev/null
+++ b/tests/pos/scala2traits/dotty-subclass.scala
@@ -0,0 +1,27 @@
+// This is supposed to be compiled by Dotty
+class Sub extends T
+
+class A extends S2T with S2Tprivate {
+ val a: Int = 3
+ var b = 2
+}
+
+object Main {
+ def main(args: Array[String]): Unit = {
+ val sub = new Sub
+ println(sub.d)
+ println(sub.v)
+ println(sub.O)
+ println(sub.w)
+
+ val a = new A
+ a.x += a.y
+ println(a.x)
+ println(a.f(a.a + a.b))
+
+ a.xx += a.yy
+ println(a.x)
+ println(a.ff(a.xx))
+ }
+}
+
diff --git a/tests/pos/scala2traits/scala-trait.scala b/tests/pos/scala2traits/scala-trait.scala
new file mode 100644
index 000000000..db05bc941
--- /dev/null
+++ b/tests/pos/scala2traits/scala-trait.scala
@@ -0,0 +1,31 @@
+// This is supposed to be compiled by Scala 2.11
+trait T {
+ def d = 42
+ val v = ""
+ object O
+ final val w = 33
+}
+
+trait S2T {
+ var x: Int = 0
+ lazy val y: Int = 1
+// val z: Int = 2
+ val a: Int
+ var b: Int
+
+ def f(x: Int): Int = x + y
+}
+
+trait S2Tprivate {
+ private var x: Int = 0
+ private lazy val y: Int = 1
+// private val z: Int = 2 // @darkdimius uncomment once lazy vals can be inherited.
+
+ private def f(x: Int): Int = x + y
+ def xx = x
+ def xx_=(x: Int) = this.x = x
+ def yy = y
+// def zz = z
+ def ff(x: Int) = f(x)
+}
+