diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/i1307.scala | 7 | ||||
-rw-r--r-- | tests/pos/i1318.scala | 38 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/pos/i1307.scala b/tests/pos/i1307.scala new file mode 100644 index 000000000..1dd922321 --- /dev/null +++ b/tests/pos/i1307.scala @@ -0,0 +1,7 @@ +class Term[A] +class Number(val n: Int) extends Term[Int] +object Test { + def f[B](t: Term[B]): B = t match { + case y: Number => y.n + } +} diff --git a/tests/pos/i1318.scala b/tests/pos/i1318.scala new file mode 100644 index 000000000..dfb882825 --- /dev/null +++ b/tests/pos/i1318.scala @@ -0,0 +1,38 @@ +object Foo { + class S(i: Int) + case class T(i: Int) extends S(i) + + object T { + def unapply(s: S): Option[(Int, Int)] = Some(5, 6) + // def unapply(o: Object): Option[(Int, Int, Int)] = Some(5, 6, 7) + } + + val s = new S(5) + + s match { + // case T(x, y, z) => println(x + y + z) + case T(x, y) => println(x + y) + case T(x) => println(x) + case _ => println("not match") + } +} + +object Bar { + case class T(i: Int) + class S(i: Int) extends T(i) + + object T { + def unapply(s: S): Option[(Int, Int)] = Some(5, 6) + // def unapply(o: Object): Option[(Int, Int, Int)] = Some(5, 6, 7) + } + + val s = new S(5) + + s match { + // case T(x, y, z) => println(x + y + z) + case T(x, y) => println(x + y) + case T(x) => println(x) + case _ => println("not match") + } +} + |