diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternMatchers.scala | 8 | ||||
-rw-r--r-- | test/files/run/patmatnew.scala | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index 7880070f6e..74d654a267 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -267,7 +267,7 @@ trait PatternMatchers { self: transform.ExplicitOuter with PatternNodes with Par } else { isImplemented(xs, guard) } - case p @ Ident(n) => null // if(n!= nme.WILDCARD && p.symbol.) CantHandleIdent else null + case p @ Ident(n) => if(guard eq EmptyTree) null else CantHandleGuard //case UnApply(fn,xs) => isImplemented(xs, guard) case UnApply(fn,xs) => @@ -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 => return {if(guard eq EmptyTree) isImplemented(ys, guard) else CantHandleGuard } } // ignore other unapplySeq occurrences, since will run into ArrayValue @@ -286,8 +286,8 @@ trait PatternMatchers { self: transform.ExplicitOuter with PatternNodes with Par case Bind(n, p) => isImplemented(p , guard) case Alternative(xs) => isImplemented(xs, guard) case p:Literal => null - case p:Select => null - case p:Typed => null + case p:Select => if(guard eq EmptyTree) null else CantHandleGuard + case p:Typed => if(guard eq EmptyTree) null else CantHandleGuard // ArrayValue nodes can also appear in repeated parameter positions of case classes (e.g. xml.Elem) case ArrayValue(_,xs) => CantHandleSeq diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 76395bd7e2..7c283fae5c 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -443,6 +443,10 @@ object Test extends TestConsoleMain { z.isDefinedAt(42) s.isDefinedAt(42) // just load the thing, to see if the classes are found + + (None:Option[Boolean]) match { + case x if x.map(x => x).isEmpty => + } } } |