diff options
author | Burak Emir <emir@epfl.ch> | 2007-08-21 22:44:21 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-08-21 22:44:21 +0000 |
commit | ea8c405c26609aaa7abd9e670ab4bf95afe0a1fa (patch) | |
tree | 635359fa23cc7a27ff23692051391e5d03e79450 | |
parent | e313d9651adc2b7137a1dabbd3b0351619383035 (diff) | |
download | scala-ea8c405c26609aaa7abd9e670ab4bf95afe0a1fa.tar.gz scala-ea8c405c26609aaa7abd9e670ab4bf95afe0a1fa.tar.bz2 scala-ea8c405c26609aaa7abd9e670ab4bf95afe0a1fa.zip |
unapplySeq-optimization works in combination wi...
unapplySeq-optimization works in combination with guards
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternMatchers.scala | 2 | ||||
-rw-r--r-- | test/files/run/patmatnew.scala | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index a4795fcdb1..7602cee7d9 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -275,7 +275,7 @@ trait PatternMatchers { self: transform.ExplicitOuter with PatternNodes with Par // List.unapply<...>(xs) case Apply(TypeApply(sel @ Select(stor, nme.unapplySeq),_),_) if(stor.symbol eq definitions.ListModule) => (xs: @unchecked) match { - case ArrayValue(_,ys)::Nil => return {if(guard eq EmptyTree) isImplemented(ys, guard) else CantHandleSeq } + case ArrayValue(_,ys)::Nil => isImplemented(ys, guard) //return {if(guard eq EmptyTree) isImplemented(ys, guard) else CantHandleSeq } } // ignore other unapplySeq occurrences, since will run into ArrayValue diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 14e349b847..36e52315a6 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -27,6 +27,7 @@ object Test extends TestConsoleMain { new TestSimpleIntSwitch, new SimpleUnapply, SeqUnapply, + applyFromJcl, new Test717, new TestGuards, TestEqualsPatternOpt, @@ -65,6 +66,16 @@ object Test extends TestConsoleMain { } } + object applyFromJcl extends TestCase("applyFromJcl") { + override def runTest { + val p = (1,2) + Some(2) match { + case Some(p._2) => ; + case _ => assert(false) ; + } + } + } + class TestSimpleIntSwitch extends TestCase("SimpleIntSwitch") { override def runTest() = { assertEquals("s1", 1, 1 match { @@ -416,5 +427,16 @@ object Test extends TestConsoleMain { println((new Buffer).jp.isDefinedAt(42)) } + object lk { // compile only + val z:PartialFunction[Any,Any] = { + case x::xs if xs.forall { y => y.hashCode() > 0 } => 1 + } + + val s:PartialFunction[Any,Any] = { + case List(x) if List(x).forall { g => g.hashCode() > 0 } => 1 + } + + } + } |