diff options
author | Paul Phillips <paulp@improving.org> | 2009-07-11 05:02:16 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-07-11 05:02:16 +0000 |
commit | 2bc40d593a84a510ccf18b1666a419f77665fcb4 (patch) | |
tree | 085c34b88c3f46ef8aaf8243bcaddd6ac1a51826 | |
parent | 8ee2c8685d4edb2d0c285aeb6fa9b2a99b8a9e79 (diff) | |
download | scala-2bc40d593a84a510ccf18b1666a419f77665fcb4.tar.gz scala-2bc40d593a84a510ccf18b1666a419f77665fcb4.tar.bz2 scala-2bc40d593a84a510ccf18b1666a419f77665fcb4.zip |
Fix and test case for #1260.
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t1260.scala (renamed from test/pending/pos/t1260.scala) | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index c79385488a..ecf3dddfea 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -983,10 +983,12 @@ trait ParallelMatching extends ast.TreeDSL { val fail = frep map (_.toTree) getOrElse (failTree) // dig out case field accessors that were buried in (***) - val cfa = if (pats.isCaseHead) casted.accessors else Nil - val caseTemps = srep.tvars match { case x :: xs if x == casted.sym => xs ; case x => x } - def needCast = if (casted.sym ne scrut.sym) List(VAL(casted.sym) === (scrut.id AS_ANY castedTpe)) else Nil - val vdefs = needCast ::: ( + val cfa = if (pats.isCaseHead) casted.accessors else Nil + val caseTemps = srep.tvars match { case x :: xs if x == casted.sym => xs ; case x => x } + def castedScrut = typedValDef(casted.sym, scrut.id AS castedTpe) + def needCast = if (casted.sym ne scrut.sym) List(castedScrut) else Nil + + val vdefs = needCast ::: ( for ((tmp, accessor) <- caseTemps zip cfa) yield typedValDef(tmp, typer typed fn(casted.id, accessor)) ) diff --git a/test/pending/pos/t1260.scala b/test/files/pos/t1260.scala index b05259998e..9cd860afd8 100644 --- a/test/pending/pos/t1260.scala +++ b/test/files/pos/t1260.scala @@ -9,8 +9,9 @@ object Test { def main(args: Array[String]) { val f = Foo("1", "2") f match { - case Foo(Bar(1), Bar(2)) => () - case Foo(Bar(i), Bar(j)) if i >= 0 => () + case Foo(Bar(1), Bar(2)) => 1 + case Foo(Bar(i), Bar(j)) if i >= 0 => 2 + case _ => 3 } } } |