Skip to content

Commit bce0df9

Browse files
committed
Fix neg tests
1 parent 5b7406f commit bce0df9

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

tests/neg/tryPatternMatchEq.scala

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.io.IOException
2+
import java.lang.NullPointerException
3+
import java.lang.IllegalArgumentException
4+
5+
object IAE {
6+
def unapply(e: Exception): Option[String] =
7+
if (e.isInstanceOf[IllegalArgumentException]) Some(e.getMessage)
8+
else None
9+
}
10+
11+
object EX extends Exception
12+
13+
trait ExceptionTrait extends Exception
14+
15+
object Test {
16+
def main(args: Array[String]): Unit = {
17+
var a: Int = 1
18+
try {
19+
throw new IllegalArgumentException()
20+
} catch {
21+
case e: IOException if e.getMessage == null =>
22+
case e: NullPointerException =>
23+
case e: IndexOutOfBoundsException =>
24+
case _: NoSuchElementException =>
25+
case _: ExceptionTrait =>
26+
case _: NoSuchElementException if a <= 1 =>
27+
case _: NullPointerException | _:IOException =>
28+
case `a` => // error: cannot compare
29+
case EX =>
30+
case IAE(msg) =>
31+
case e: IllegalArgumentException =>
32+
}
33+
}
34+
}

tests/neg/tryPatternMatchError.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ object Test {
2525
case _: ExceptionTrait =>
2626
case _: NoSuchElementException if a <= 1 =>
2727
case _: NullPointerException | _:IOException =>
28-
case `a` => // This case should probably emmit an error
2928
case e: Int => // error
3029
case EX =>
3130
case IAE(msg) =>

0 commit comments

Comments
 (0)