diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t9398.check | 7 | ||||
-rw-r--r-- | test/files/neg/t9398.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t9398/data.scala | 5 | ||||
-rw-r--r-- | test/files/neg/t9398/match.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t9629.check | 17 | ||||
-rw-r--r-- | test/files/neg/t9629.scala | 12 | ||||
-rw-r--r-- | test/files/pos/t5899.scala | 1 | ||||
-rw-r--r-- | test/files/pos/t9399.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9399.scala | 17 | ||||
-rw-r--r-- | test/files/pos/t9411a.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9411a.scala | 27 | ||||
-rw-r--r-- | test/files/pos/t9411b.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9411b.scala | 36 | ||||
-rw-r--r-- | test/files/pos/t9630.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9630/t9630a.scala | 9 | ||||
-rw-r--r-- | test/files/pos/t9630/t9630b.scala | 8 | ||||
-rw-r--r-- | test/files/run/Course-2002-07.scala | 2 | ||||
-rw-r--r-- | test/files/run/caseclasses.scala | 2 | ||||
-rw-r--r-- | test/files/run/infix.scala | 1 | ||||
-rw-r--r-- | test/files/run/patmatnew.scala | 4 | ||||
-rw-r--r-- | test/files/run/t3126.scala | 2 | ||||
-rw-r--r-- | test/files/run/t4124.scala | 8 | ||||
-rw-r--r-- | test/files/run/t6089.scala | 2 | ||||
-rw-r--r-- | test/files/run/t7459f.scala | 2 |
24 files changed, 162 insertions, 11 deletions
diff --git a/test/files/neg/t9398.check b/test/files/neg/t9398.check new file mode 100644 index 0000000000..f0c464daa1 --- /dev/null +++ b/test/files/neg/t9398.check @@ -0,0 +1,7 @@ +match.scala:3: warning: match may not be exhaustive. +It would fail on the following input: CC(B2) + def test(c: CC): Unit = c match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t9398.flags b/test/files/neg/t9398.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t9398.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t9398/data.scala b/test/files/neg/t9398/data.scala new file mode 100644 index 0000000000..7a98c0e8e8 --- /dev/null +++ b/test/files/neg/t9398/data.scala @@ -0,0 +1,5 @@ +sealed abstract class TB +case object B extends TB +case object B2 extends TB + +case class CC(tb: TB) diff --git a/test/files/neg/t9398/match.scala b/test/files/neg/t9398/match.scala new file mode 100644 index 0000000000..e110c6a96a --- /dev/null +++ b/test/files/neg/t9398/match.scala @@ -0,0 +1,6 @@ +class Test { + // Should warn that CC(B2) isn't matched + def test(c: CC): Unit = c match { + case CC(B) => () + } +} diff --git a/test/files/neg/t9629.check b/test/files/neg/t9629.check new file mode 100644 index 0000000000..4eafa84236 --- /dev/null +++ b/test/files/neg/t9629.check @@ -0,0 +1,17 @@ +t9629.scala:4: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case Option[Int] => // error was issued before + ^ +t9629.scala:5: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case Some(Option[Int]) => // error was skipped, patmat issued an internal error + ^ +t9629.scala:8: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case (_, Option[Int]) => + ^ +t9629.scala:9: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case x @ (y @ Option[Int]) => + ^ +four errors found diff --git a/test/files/neg/t9629.scala b/test/files/neg/t9629.scala new file mode 100644 index 0000000000..2be2b039f2 --- /dev/null +++ b/test/files/neg/t9629.scala @@ -0,0 +1,12 @@ +class Test { + def foo(a: Any) { + a match { + case Option[Int] => // error was issued before + case Some(Option[Int]) => // error was skipped, patmat issued an internal error + + // variations + case (_, Option[Int]) => + case x @ (y @ Option[Int]) => + } + } +} diff --git a/test/files/pos/t5899.scala b/test/files/pos/t5899.scala index b16f1f84fe..885baca790 100644 --- a/test/files/pos/t5899.scala +++ b/test/files/pos/t5899.scala @@ -14,6 +14,7 @@ trait Foo { Bippy(Stable) match { case Bippy(nme.WILDCARD) => 1 case Bippy(Stable) => 2 // should not be considered unreachable + case Bippy(_) => 3 } } }
\ No newline at end of file diff --git a/test/files/pos/t9399.flags b/test/files/pos/t9399.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9399.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9399.scala b/test/files/pos/t9399.scala new file mode 100644 index 0000000000..e8a8720f94 --- /dev/null +++ b/test/files/pos/t9399.scala @@ -0,0 +1,17 @@ +sealed abstract class TA +sealed abstract class TB extends TA +case object A extends TA +case object B extends TB + +sealed trait C +case class CTA(id: Int, da: TA) extends C +case class CTB(id: Int, da: TB) extends C + +class Test { + def test(c: C): Unit = c match { + case CTA(_, A) => + case CTA(_, B) => + case CTB(_, B) => + } +} + diff --git a/test/files/pos/t9411a.flags b/test/files/pos/t9411a.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9411a.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9411a.scala b/test/files/pos/t9411a.scala new file mode 100644 index 0000000000..d5264663ec --- /dev/null +++ b/test/files/pos/t9411a.scala @@ -0,0 +1,27 @@ +object OhNoes { + + sealed trait F + sealed abstract class FA extends F + sealed abstract class FB extends F + + case object FA1 extends FA + case object FB1 extends FB + case object FB2 extends FB + + sealed trait G + case object G1 extends G + case object G2 extends G + + sealed trait H + case class H1(a: FB, b: G) extends H + case class H2(a: F) extends H + + val demo: H => Unit = { + case H1(FB1, G1) => + case H1(FB2, G2) => + case H2(_: FB) => + case H2(_: FA) => + case H1(FB1, G2) => + case H1(FB2, G1) => + } +} diff --git a/test/files/pos/t9411b.flags b/test/files/pos/t9411b.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9411b.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9411b.scala b/test/files/pos/t9411b.scala new file mode 100644 index 0000000000..6888ba9382 --- /dev/null +++ b/test/files/pos/t9411b.scala @@ -0,0 +1,36 @@ +object OhNoes { + + sealed trait F + sealed abstract class FA extends F + sealed abstract class FB extends F + + case object FA1 extends FA + case object FB1 extends FB + case object FB2 extends FB + + sealed trait G + case object G1 extends G + case object G2 extends G + + sealed trait H + case class H1(a: FB, b: G) extends H + case class H2(b: F) extends H + + val demo: H => Unit = { + case H1(FB1, G1) => + case H1(FB2, G2) => + case H2(_: FB) => + case H2(_: FA) => + case H1(FB1, G2) => + case H1(FB2, G1) => + } + + val demo2: H => Unit = { + case H2(_: FA) => + case H2(_: FB) => + case H1(FB1, G1) => + case H1(FB2, G1) => + case H1(FB1, G2) => + case H1(FB2, G2) => + } +} diff --git a/test/files/pos/t9630.flags b/test/files/pos/t9630.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9630.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9630/t9630a.scala b/test/files/pos/t9630/t9630a.scala new file mode 100644 index 0000000000..c76ecd2ff2 --- /dev/null +++ b/test/files/pos/t9630/t9630a.scala @@ -0,0 +1,9 @@ + +sealed trait Base +final case class Base_1(sameName: Some[Any]) extends Base +final case class Base_2(sameName: Nested) extends Base + +sealed trait Nested +final case class Nested_1(x: Any) extends Nested +final case class Nested_2(y: Any) extends Nested + diff --git a/test/files/pos/t9630/t9630b.scala b/test/files/pos/t9630/t9630b.scala new file mode 100644 index 0000000000..3e1787ec52 --- /dev/null +++ b/test/files/pos/t9630/t9630b.scala @@ -0,0 +1,8 @@ + +class Test { + def test(b: Base): Unit = b match { + case Base_1(Some(_)) => + case Base_2(Nested_1(_)) => + case Base_2(Nested_2(_)) => + } +} diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 2d9457653f..db6e1d8e04 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -485,7 +485,7 @@ object MB { import Utils._; - trait Expr { + sealed trait Expr { private def count: Int = this match { case Lit(n) => n diff --git a/test/files/run/caseclasses.scala b/test/files/run/caseclasses.scala index 668c984f3d..10c0916dc0 100644 --- a/test/files/run/caseclasses.scala +++ b/test/files/run/caseclasses.scala @@ -18,7 +18,7 @@ object M { object Test extends App { def Abs(x: Int) = new Abs(x * 2){} - Abs(2) match { + (Abs(2): @unchecked) match { case Abs(4) => ; } diff --git a/test/files/run/infix.scala b/test/files/run/infix.scala index a867d03ce8..1d39003644 100644 --- a/test/files/run/infix.scala +++ b/test/files/run/infix.scala @@ -7,5 +7,6 @@ object Test extends App { Console.println(xs) xs match { case null op (0, 0) op (1, 1) op (2, 2) => Console.println("OK") + case _ => } } diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 3c0d00dc6c..2647d97836 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -539,7 +539,7 @@ object Test { case class Operator(x: Int); val EQ = new Operator(2); - def analyze(x: Tuple2[Operator, Int]) = x match { + def analyze(x: Tuple2[Operator, Int]) = (x: @unchecked) match { case (EQ, 0) => "0" case (EQ, 1) => "1" case (EQ, 2) => "2" @@ -603,7 +603,7 @@ object Test { object Bug1093 { def run() { - assert(Some(3) match { + assert((Some(3): @unchecked) match { case Some(1 | 2) => false case Some(3) => true }) diff --git a/test/files/run/t3126.scala b/test/files/run/t3126.scala index 36322bf896..865047ce4f 100644 --- a/test/files/run/t3126.scala +++ b/test/files/run/t3126.scala @@ -4,6 +4,6 @@ object Test { def main(args: Array[String]): Unit = { try C.unapply(null) catch { case _: MatchError => } - try v match { case Some(1) => } catch { case _: MatchError => } + try ((v: @unchecked) match { case Some(1) => }) catch { case _: MatchError => } } } diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala index 9f35b57ce3..db4e382634 100644 --- a/test/files/run/t4124.scala +++ b/test/files/run/t4124.scala @@ -2,22 +2,22 @@ import xml.Node object Test extends App { val body: Node = <elem>hi</elem> - println ((body: AnyRef, "foo") match { + println (((body: AnyRef, "foo"): @unchecked) match { case (node: Node, "bar") => "bye" case (ser: Serializable, "foo") => "hi" }) - println ((body, "foo") match { + println (((body, "foo"): @unchecked) match { case (node: Node, "bar") => "bye" case (ser: Serializable, "foo") => "hi" }) - println ((body: AnyRef, "foo") match { + println (((body: AnyRef, "foo"): @unchecked) match { case (node: Node, "foo") => "bye" case (ser: Serializable, "foo") => "hi" }) - println ((body: AnyRef, "foo") match { + println (((body: AnyRef, "foo"): @unchecked) match { case (node: Node, "foo") => "bye" case (ser: Serializable, "foo") => "hi" }) diff --git a/test/files/run/t6089.scala b/test/files/run/t6089.scala index c72d7ba792..c42a9f68c6 100644 --- a/test/files/run/t6089.scala +++ b/test/files/run/t6089.scala @@ -3,7 +3,7 @@ case class Foo(x: Int) object Test { def bippo(result: Boolean): Boolean = result def bungus(m: Foo): Boolean = - bippo(m match { case Foo(2) => bungus(m) }) + bippo((m: @unchecked) match { case Foo(2) => bungus(m) }) def main(args: Array[String]): Unit = try { bungus(Foo(0)) diff --git a/test/files/run/t7459f.scala b/test/files/run/t7459f.scala index 63e2109560..5cd972129a 100644 --- a/test/files/run/t7459f.scala +++ b/test/files/run/t7459f.scala @@ -3,7 +3,7 @@ object Test extends App { case class FooSeq(x: Int, y: String, z: C*) - FooSeq(1, "a", new C()) match { + (FooSeq(1, "a", new C()): @unchecked) match { case FooSeq(1, "a", x@_* ) => //println(x.toList) x.asInstanceOf[x.type] |