diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 14 | ||||
-rw-r--r-- | test/files/run/patmatnew.scala | 15 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index a1a9848f1e..44b5d7102a 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -333,16 +333,20 @@ trait ParallelMatching { /*block*/{ var xs = column var i = 0; -// var last = -1; + var last = -1; while(xs ne Nil) { // forall -// if (last != -1) { -// cunit.error(xs.head.pos, "unreachable code") -// } + if (last != -1) { + cunit.error(xs.head.pos, "unreachable code") + } strip(xs.head) match { case (pvars, p @ Literal(Constant(c:Int))) => sanity(p.pos, c , definedVars(xs.head)); insertTagIndexPair(c,i) case (pvars, p @ Literal(Constant(c:Char))) => sanity(p.pos, c.toInt, definedVars(xs.head)); insertTagIndexPair(c.toInt,i) case (pvars, p ) if isDefaultPattern(p) => insertDefault(i,pvars) -// case (pvars, p ) if isDefaultPattern(p) => last = i; insertDefault(i,pvars) + case (pvars, p ) if isDefaultPattern(p) => + if (rest.row(i).guard == EmptyTree) { + last = i; + } + insertDefault(i,pvars) } i += 1 xs = xs.tail diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 6ec3928757..d78be53eef 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -824,6 +824,21 @@ object Test extends TestConsoleMain { } } + object Ticket495bis { // compile-only + def signum(x: Int): Int = + x match { + case 0 => 0 + case _ if x < 0 => -1 + case _ if x > 0 => 1 + } + def pair_m(x: Int, y: Int) = + (x,y) match { + case (_, 0) => 0 + case (-1, _) => -1 + case (_, _) => 1 + } + } + object Ticket522 { // compile-only class Term[X] object App { |