From e76507f8793cd025b56ba2a0c3b0cc112bcc8aea Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 15 Aug 2013 15:02:19 -0700 Subject: An Unapplied extractor. This makes it a lot less error prone and redundant to find the part you need when unwrapping an UnApply tree. --- src/compiler/scala/reflect/reify/phases/Reshape.scala | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index b6f27f71ce..7610df67dc 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -8,6 +8,7 @@ trait Reshape { import global._ import definitions._ + import treeInfo.Unapplied /** * Rolls back certain changes that were introduced during typechecking of the reifee. @@ -65,22 +66,9 @@ trait Reshape { case block @ Block(stats, expr) => val stats1 = reshapeLazyVals(trimSyntheticCaseClassCompanions(stats)) Block(stats1, expr).copyAttrs(block) - case unapply @ UnApply(fun, args) => - def extractExtractor(tree: Tree): Tree = { - val Apply(fun, args) = tree - args match { - case List(Ident(special)) if special == nme.SELECTOR_DUMMY => - val Select(extractor, flavor) = fun - assert(flavor == nme.unapply || flavor == nme.unapplySeq) - extractor - case _ => - extractExtractor(fun) - } - } - + case unapply @ UnApply(Unapplied(Select(fun, nme.unapply | nme.unapplySeq)), args) => if (reifyDebug) println("unapplying unapply: " + tree) - val fun1 = extractExtractor(fun) - Apply(fun1, args).copyAttrs(unapply) + Apply(fun, args).copyAttrs(unapply) case _ => tree } -- cgit v1.2.3