From fbd2b0caac60c33408c0dd1906855617c4e188fb Mon Sep 17 00:00:00 2001 From: Burak Emir Date: Mon, 7 Apr 2008 01:37:29 +0000 Subject: fixed #522 --- .../scala/tools/nsc/matching/ParallelMatching.scala | 12 ++++++++---- test/files/run/patmatnew.scala | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 5b6e565e04..9204b6f1db 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -396,8 +396,9 @@ trait ParallelMatching { } } val ures = newVarCapture(ua.pos, app.tpe) - val n = args.length - val uacall = typedValDef(ures, Apply(fn, mkIdent(scrutinee) :: appargs.tail)) + val arg0 = mkIdent(scrutinee) + val rhs = Apply(fn, arg0 :: appargs.tail) setType ures.tpe + val uacall = typedValDef(ures, rhs) val nrowsOther = column.tail.zip(rest.row.tail) flatMap { case (pat, Row(ps, subst, g, bx)) => @@ -405,8 +406,11 @@ trait ParallelMatching { case sameUnapplyCall(_) => Nil case _ => List(Row(pat::ps, subst, g, bx)) }} - val nrepFail = if (nrowsOther.isEmpty) None else Some(rep.make(scrutinee::rest.temp, nrowsOther)) - n match { + val nrepFail = if (nrowsOther.isEmpty) + None + else + Some(rep.make(scrutinee::rest.temp, nrowsOther)) + args.length match { case 0 => // special case for unapply(), app.tpe is boolean val ntemps = scrutinee :: rest.temp val nrows = column.zip(rest.row) map { diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 51c823f7ac..6ec3928757 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -823,6 +823,27 @@ object Test extends TestConsoleMain { } } } + + object Ticket522 { // compile-only + class Term[X] + object App { + // i'm hidden + case class InternalApply[Y,Z](fun:Y=>Z, arg:Y) extends Term[Z] + + def apply[Y,Z](fun:Y=>Z, arg:Y): Term[Z] = + new InternalApply[Y,Z](fun,arg) + + def unapply[X](arg: Term[X]): Option[(Y=>Z,Y)] forSome {type Y; type Z} = + arg match { + case i:InternalApply[y,z] => Some(i.fun, i.arg) + case _ => None + } + } + + App({x: Int => x}, 5) match { + case App(arg, a) => + } + } // end Ticket522 } -- cgit v1.2.3