Permalink
Browse files

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`.
  • Loading branch information...
1 parent fbbe7cc commit 9737b808c12821162e2a5888b17175a396037f50 @xeno-by xeno-by committed Dec 7, 2013
@@ -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,29 +701,14 @@ 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
}
}
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
})
@@ -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))
@@ -1,4 +1,4 @@
-// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here
+// see the comments for macroExpand.onDelayed for an explanation of what's tested here
object Test extends App {
case class Foo(i: Int, s: String, b: Boolean)
def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
@@ -1,4 +1,4 @@
-// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here
+// see the comments for macroExpand.onDelayed for an explanation of what's tested here
object Test extends App {
case class Foo(i: Int, s: String, b: Boolean)
def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)

0 comments on commit 9737b80

Please sign in to comment.