From 2465b7e2aaddefb2204e3dec32ca6c0f3cbe681b Mon Sep 17 00:00:00 2001 From: Burak Emir Date: Tue, 14 Aug 2007 16:24:20 +0000 Subject: implemented #1196 by typer change and added tes... implemented #1196 by typer change and added test cases --- test/files/run/patmatnew.scala | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'test/files/run/patmatnew.scala') diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index a54bac814f..1d4bf37e1a 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -289,5 +289,49 @@ object Test extends TestConsoleMain { case FooBar => true } + object Bug1270 { // unapply13 + + class Sync { + def apply(x: Int): Int = 42 + def unapply(scrut: Any): Option[Int] = None + } + + class Buffer { + object Get extends Sync + + var ps: PartialFunction[Any, Any] = { + case Get(y) if y > 4 => // y gets a wildcard type for some reason?! hack + } + } + + println((new Buffer).ps.isDefinedAt(42)) + } + + object Bug1261 { + sealed trait Elem + case class Foo extends Elem + case class Bar extends Elem + trait Row extends Elem + object Row { + def unapply(r: Row) = true + + def f(elem: Elem) { + elem match { + case Bar() => ; + case Row() => ; + case Foo() => ; // used to give ERROR (unreachable code) + }}} + } + + object Feature1196 { + def f(l: List[Int]) { } + + val l: Seq[Int] = List(1, 2, 3) + + l match { + case x @ List(1, _) => f(x) // x needs to get better type List[int] here + } + } + } -- cgit v1.2.3