From a8d0af946416a012abdfd7cb1933f3fb7325035c Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sun, 2 Dec 2012 03:17:20 -0500 Subject: [PATCH] split out KeyMacro.enclosingTrees --- main/settings/KeyMacro.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/settings/KeyMacro.scala b/main/settings/KeyMacro.scala index 7d7c2ee6e..c35819e8f 100644 --- a/main/settings/KeyMacro.scala +++ b/main/settings/KeyMacro.scala @@ -32,12 +32,13 @@ object KeyMacro { import c.universe.{Apply=>ApplyTree,_} val methodName = c.macroApplication.symbol.name.decoded - val enclosingTrees = c.asInstanceOf[reflect.macros.runtime.Context].callsiteTyper.context.enclosingContextChain.map(_.tree.asInstanceOf[Tree]) - enclosingTrees match { + enclosingTrees(c) match { case vd @ ValDef(_, name, _, _) :: ts => name.decoded case _ => c.error(c.enclosingPosition, s"""$methodName must be directly assigned to a val, such as `val x = $methodName[Int]("description")`.""") "" } } + def enclosingTrees(c: Context): Seq[c.Tree] = + c.asInstanceOf[reflect.macros.runtime.Context].callsiteTyper.context.enclosingContextChain.map(_.tree.asInstanceOf[c.Tree]) } \ No newline at end of file