summaryrefslogtreecommitdiff
path: root/test/files/pos/t267.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-08-24 17:11:55 +0000
committerPaul Phillips <paulp@improving.org>2011-08-24 17:11:55 +0000
commitb9785280a7138a2bb52060faf94807aa0d07dec1 (patch)
tree870cc1930ac3d50cd07078260f58984224dd39a5 /test/files/pos/t267.scala
parent84fcf633d9ca507124806d64729cb8463bcebb69 (diff)
downloadscala-b9785280a7138a2bb52060faf94807aa0d07dec1.tar.gz
scala-b9785280a7138a2bb52060faf94807aa0d07dec1.tar.bz2
scala-b9785280a7138a2bb52060faf94807aa0d07dec1.zip
Renamed tests named bugXXX to tXXX, no review.
Diffstat (limited to 'test/files/pos/t267.scala')
-rw-r--r--test/files/pos/t267.scala55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/files/pos/t267.scala b/test/files/pos/t267.scala
new file mode 100644
index 0000000000..7e5876eae9
--- /dev/null
+++ b/test/files/pos/t267.scala
@@ -0,0 +1,55 @@
+package expAbstractData
+
+/** A base class consisting of
+ * - a root trait (i.e. abstract class) `Exp' with an `eval' function
+ * - an abstract type `exp' bounded by `Exp'
+ * - a concrete instance class `Num' of `Exp' for numeric literals
+ */
+trait Base {
+ type exp <: Exp
+
+ trait Exp {
+ def eval: Int
+ }
+ class Num(v: Int) extends Exp { self: exp =>
+ val value = v
+ def eval = value
+ }
+}
+
+object testBase extends App with Base {
+ type exp = Exp
+ val term = new Num(2);
+ Console.println(term.eval)
+}
+
+/** Data extension: An extension of `Base' with `Plus' expressions
+ */
+trait BasePlus extends Base {
+ class Plus(l: exp, r: exp) extends Exp { self: exp =>
+ val left = l
+ val right = r
+ def eval = left.eval + right.eval
+ }
+}
+
+/** Operation extension: An extension of `Base' with 'show' methods.
+ */
+trait Show extends Base {
+ type exp <: Exp1
+
+ trait Exp1 extends Exp {
+ def show: String
+ }
+ class Num1(v: Int) extends Num(v) with Exp1 { self: exp with Num1 =>
+ def show = value.toString()
+ }
+}
+
+/** Operation extension: An extension of `BasePlus' with 'show' methods.
+ */
+trait ShowPlus extends BasePlus with Show {
+ class Plus1(l: exp, r: exp) extends Plus(l, r) with Exp1 { self: exp with Plus1 =>
+ def show = left.show + " + " + right.show
+ }
+}