diff options
author | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-03-06 17:45:49 +0200 |
---|---|---|
committer | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-03-10 20:35:22 +0200 |
commit | 6dbd770b41ae125c4c11158c687f68452b09e51f (patch) | |
tree | c93c5fb38b857171215077a26151bf1ea3843d2d /src/compiler | |
parent | 7f07d44bcc97ba8435e8c77393554571c9a006ad (diff) | |
download | scala-6dbd770b41ae125c4c11158c687f68452b09e51f.tar.gz scala-6dbd770b41ae125c4c11158c687f68452b09e51f.tar.bz2 scala-6dbd770b41ae125c4c11158c687f68452b09e51f.zip |
SI-8366 make partial function and match trees disjoint
Previously one could match a partial function with match quasiquote:
scala> val q"$scrutinee match { case ..$cases }" = q"{ case Foo => Bar
}"
scrutinee: universe.Tree = <empty>
cases: List[universe.CaseDef] = List(case Foo => Bar)
This was quite annoying as it leaked encoding of partial functions as
Match trees with empty tree in place of scrutinee.
This commit make sure that matches and partial functions are disjoint
and don't match one another (while preserving original encoding under
the hood out of sight of the end user.)
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala index 850030e9ba..1b8b0686e8 100644 --- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala +++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala @@ -199,6 +199,10 @@ trait Reifiers { self: Quasiquotes => reifyBuildCall(nme.SyntacticEmptyTypeTree) case SyntacticImport(expr, selectors) => reifyBuildCall(nme.SyntacticImport, expr, selectors) + case SyntacticPartialFunction(cases) => + reifyBuildCall(nme.SyntacticPartialFunction, cases) + case SyntacticMatch(scrutinee, cases) => + reifyBuildCall(nme.SyntacticMatch, scrutinee, cases) case Q(tree) if fillListHole.isDefinedAt(tree) => mirrorBuildCall(nme.SyntacticBlock, fillListHole(tree)) case Q(other) => @@ -211,8 +215,6 @@ trait Reifiers { self: Quasiquotes => reifyBuildCall(nme.SyntacticBlock, Nil) case Try(block, catches, finalizer) => reifyBuildCall(nme.SyntacticTry, block, catches, finalizer) - case Match(selector, cases) => - reifyBuildCall(nme.SyntacticMatch, selector, cases) case CaseDef(pat, guard, body) if fillListHole.isDefinedAt(body) => mirrorCall(nme.CaseDef, reify(pat), reify(guard), mirrorBuildCall(nme.SyntacticBlock, fillListHole(body))) // parser emits trees with scala package symbol to ensure |