diff options
author | Martin Odersky <odersky@gmail.com> | 2006-11-16 11:02:01 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-11-16 11:02:01 +0000 |
commit | cb7711db82c381848a6571047c68145e4f2d3c46 (patch) | |
tree | 3d05732f8866d02c886c4a71a17804367ee217db /test/files/run | |
parent | 821551dd7f72b70b786919efcb58c88a236685ce (diff) | |
download | scala-cb7711db82c381848a6571047c68145e4f2d3c46.tar.gz scala-cb7711db82c381848a6571047c68145e4f2d3c46.tar.bz2 scala-cb7711db82c381848a6571047c68145e4f2d3c46.zip |
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/bug789.check | 2 | ||||
-rw-r--r-- | test/files/run/bug789.scala | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/test/files/run/bug789.check b/test/files/run/bug789.check new file mode 100644 index 0000000000..a98c09dcac --- /dev/null +++ b/test/files/run/bug789.check @@ -0,0 +1,2 @@ +hello size 42 +hello size 42 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)) + } +} |