From cb7711db82c381848a6571047c68145e4f2d3c46 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 16 Nov 2006 11:02:01 +0000 Subject: --- test/files/neg/overload.check | 7 +++++++ test/files/neg/overload.scala | 11 +++++++++++ test/files/pos/bug803.scala | 2 ++ test/files/pos/bug805.scala | 19 +++++++++++++++++++ test/files/pos/bug812.scala | 7 +++++++ test/files/run/bug789.check | 2 ++ test/files/run/bug789.scala | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 80 insertions(+) create mode 100644 test/files/neg/overload.check create mode 100644 test/files/neg/overload.scala create mode 100644 test/files/pos/bug803.scala create mode 100644 test/files/pos/bug805.scala create mode 100644 test/files/pos/bug812.scala create mode 100644 test/files/run/bug789.check create mode 100644 test/files/run/bug789.scala (limited to 'test/files') diff --git a/test/files/neg/overload.check b/test/files/neg/overload.check new file mode 100644 index 0000000000..65e6a9dc81 --- /dev/null +++ b/test/files/neg/overload.check @@ -0,0 +1,7 @@ +overload.scala:10 error: erroneous reference to overloaded definition, +most specific definition is: method f in class C of type (scala.Int)scala.Unit, +yet alternative definition method f in class D of type (scala.Any)scala.Unit +is defined in a subclass + (new D).f(1) + ^ +one error found diff --git a/test/files/neg/overload.scala b/test/files/neg/overload.scala new file mode 100644 index 0000000000..311ea3874b --- /dev/null +++ b/test/files/neg/overload.scala @@ -0,0 +1,11 @@ +class C { + def f(x: int) {} +} + +class D extends C { + def f(x: Any) {} +} + +object Test { + (new D).f(1) +} diff --git a/test/files/pos/bug803.scala b/test/files/pos/bug803.scala new file mode 100644 index 0000000000..066abecffa --- /dev/null +++ b/test/files/pos/bug803.scala @@ -0,0 +1,2 @@ +class B(x : () => Int) +class A(i : Int) extends B(() => i) { i } diff --git a/test/files/pos/bug805.scala b/test/files/pos/bug805.scala new file mode 100644 index 0000000000..37bf6b5ef8 --- /dev/null +++ b/test/files/pos/bug805.scala @@ -0,0 +1,19 @@ +trait MatcherYYY { + trait NodeImpl; + trait Matchable extends NodeImpl { + protected def doMatch : Unit = {} + } +} +trait BraceMatcherXXX extends MatcherYYY { + trait NodeImpl extends super.NodeImpl { + def doMatch (braces : BracePair) : Unit + } + trait BracePair { + trait BraceImpl extends NodeImpl with Matchable { + override def doMatch : Unit = { + super.doMatch; + (); + } + } + } +} diff --git a/test/files/pos/bug812.scala b/test/files/pos/bug812.scala new file mode 100644 index 0000000000..ccbe6db5ce --- /dev/null +++ b/test/files/pos/bug812.scala @@ -0,0 +1,7 @@ +package test; +import scala.{Application => Main}; +class Test extends Main { + import test.{Test => Hello} + super[Application].executionStart; + private[Test] def xxx = 10; +} 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)) + } +} -- cgit v1.2.3