aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pos/scala2traits/dotty-subclass.scala27
-rw-r--r--tests/pos/scala2traits/scala-trait.scala31
-rw-r--r--tests/run/t6534.scala10
3 files changed, 66 insertions, 2 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)
+}
+
diff --git a/tests/run/t6534.scala b/tests/run/t6534.scala
index 33df97e41..b5789f52c 100644
--- a/tests/run/t6534.scala
+++ b/tests/run/t6534.scala
@@ -8,7 +8,13 @@ object Test {
def main(args: Array[String]): Unit = {
val b1 = new Bippy1(71)
val b2 = new Bippy2(71)
- assert(b1 == b1 && b1.## == b1.x.##, ((b1, b1.##)))
- assert(b2 == b2 && b2.## == b2.x.##, ((b2, b2.##)))
+ assert(b1 == b1)
+ assert(b1.## == b1.x.##, "hash differs1 " + ((b1, b1.##)))
+ assert(b2 == b2)
+ // assert(b2.## == b2.x.##, "hash differs2 " + ((b2, b2.##, b2.x.##)))
+ // Disabled, this does not hold. Because the value class inherits
+ // a different hashCode, no code is generated for it. Replaced by:
+ assert(b2.## == -1)
+ assert(!b1.equals(b1))
}
}