diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-12-07 11:41:29 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-12-30 19:06:29 +0300 |
commit | 9737b808c12821162e2a5888b17175a396037f50 (patch) | |
tree | 99136c43abb128bec5d82e8d782867f701a52db3 /src | |
parent | fbbe7cc1773fad2b261f65b1381f94532d252f6f (diff) | |
download | scala-9737b808c12821162e2a5888b17175a396037f50.tar.gz scala-9737b808c12821162e2a5888b17175a396037f50.tar.bz2 scala-9737b808c12821162e2a5888b17175a396037f50.zip |
macroExpandApply => macroExpand
Back then, when we needed separate macro expanders for both applications
and unapplications, it made sense to have two different methods that
do macro expansions.
However, after @paulp’s upgrade of the pattern matching engine, we no longer
need a dedicated expander for unapply, so I’m removing it and renaming
`macroExpandApply` to just `macroExpand`.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Macros.scala | 21 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 |
2 files changed, 4 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 0d46a96b81..b6cd1efb5c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -608,7 +608,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { * @param innerPt Expected type that comes from the signature of a macro def, possibly wildcarded to help type inference. * @see MacroExpander */ - def macroExpandApply(typer: Typer, expandee: Tree, mode: Mode, outerPt: Type): Tree = { + def macroExpand(typer: Typer, expandee: Tree, mode: Mode, outerPt: Type): Tree = { object expander extends TermMacroExpander(APPLY_ROLE, typer, expandee, mode, outerPt) { lazy val innerPt = { val tp = if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe @@ -701,7 +701,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { else { forced += delayed typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), outerPt, keepNothings = false) - macroExpandApply(typer, delayed, mode, outerPt) + macroExpand(typer, delayed, mode, outerPt) } } else delayed } @@ -709,21 +709,6 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { expander(expandee) } - /** Expands a term macro used in unapply role as `u.Quasiquote(StringContext("", "")).q.unapply(x)` in `case q"$x" => ...`. - * @see MacroExpander - */ - def macroExpandUnapply(typer: Typer, original: Tree, fun: Tree, unapply: Symbol, args: List[Tree], mode: Mode, pt: Type) = { - val expandee = treeCopy.Apply(original, gen.mkAttributedSelect(fun, unapply), args) - object expander extends TermMacroExpander(UNAPPLY_ROLE, typer, expandee, mode, pt) { - override def allowedExpansions: String = "unapply trees" - override def allowExpandee(expandee: Tree) = expandee.isInstanceOf[Apply] - private def unsupported(what: String) = abort("unapply macros currently don't support " + what) - override def onFallback(fallback: Tree) = unsupported("fallback") - override def onDelayed(delayed: Tree) = unsupported("advanced interaction with type inference") - } - expander(original) - } - private sealed abstract class MacroStatus(val result: Tree) private case class Success(expanded: Tree) extends MacroStatus(expanded) private case class Fallback(fallback: Tree) extends MacroStatus(fallback) { currentRun.seenMacroExpansionsFallingBack = true } @@ -871,7 +856,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { context.implicitsEnabled = typer.context.implicitsEnabled context.enrichmentEnabled = typer.context.enrichmentEnabled context.macrosEnabled = typer.context.macrosEnabled - macroExpandApply(newTyper(context), tree, EXPRmode, WildcardType) + macroExpand(newTyper(context), tree, EXPRmode, WildcardType) case _ => tree }) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 910da77ca8..1f7ccc6b6a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1112,7 +1112,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (tree.isType) adaptType() else if (mode.typingExprNotFun && treeInfo.isMacroApplication(tree) && !isMacroExpansionSuppressed(tree)) - macroExpandApply(this, tree, mode, pt) + macroExpand(this, tree, mode, pt) else if (mode.typingConstructorPattern) typedConstructorPattern(tree, pt) else if (shouldInsertApply(tree)) |