From b2093f2345b991fa4774950c5505621ab6445897 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 25 Jan 2016 22:11:19 +1000 Subject: SI-9629 Emit missing 'pattern must be a value' error The error used to only be emitted for top-level patterns. This commit moves it into `typedInternal` so it works for nested patterns. It uses the typer mode to know when to fire. --- test/files/neg/t9629.check | 17 +++++++++++++++++ test/files/neg/t9629.scala | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/files/neg/t9629.check create mode 100644 test/files/neg/t9629.scala (limited to 'test/files') 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]) => + } + } +} -- cgit v1.2.3