summaryrefslogtreecommitdiff
path: root/test/files/run/bug789.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-11-16 11:02:01 +0000
committerMartin Odersky <odersky@gmail.com>2006-11-16 11:02:01 +0000
commitcb7711db82c381848a6571047c68145e4f2d3c46 (patch)
tree3d05732f8866d02c886c4a71a17804367ee217db /test/files/run/bug789.scala
parent821551dd7f72b70b786919efcb58c88a236685ce (diff)
downloadscala-cb7711db82c381848a6571047c68145e4f2d3c46.tar.gz
scala-cb7711db82c381848a6571047c68145e4f2d3c46.tar.bz2
scala-cb7711db82c381848a6571047c68145e4f2d3c46.zip
Diffstat (limited to 'test/files/run/bug789.scala')
-rw-r--r--test/files/run/bug789.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/files/run/bug789.scala b/test/files/run/bug789.scala
new file mode 100644
index 0000000000..5a3c8d61e8
--- /dev/null
+++ b/test/files/run/bug789.scala
@@ -0,0 +1,32 @@
+object Test { // don't do this at home
+
+ trait Impl
+
+ trait SizeImpl extends Impl { def size = 42 }
+
+ trait ColorImpl extends Impl { def color = "red" }
+
+ type Both = SizeImpl with ColorImpl
+
+ def info(x:Impl) = x match {
+ case x:Both => "size "+x.size+" color "+x.color // you wish
+ case x:SizeImpl => "size "+x.size
+ case x:ColorImpl => "color "+x.color
+ case _ => "n.a."
+ }
+
+ def info2(x:Impl) = x match {
+ case x:SizeImpl with ColorImpl => "size "+x.size+" color "+x.color // you wish
+ case x:SizeImpl => "size "+x.size
+ case x:ColorImpl => "color "+x.color
+ case _ => "n.a."
+ }
+
+
+ def main(args:Array[String]): Unit = {
+ // make up some class that has a size
+ class MyNode extends SizeImpl
+ Console.println("hello " + info(new MyNode))
+ Console.println("hello " + info2(new MyNode))
+ }
+}