summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-07-24 12:04:57 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-08-02 15:50:59 +0200
commit280c4906d18fd827e2c934af49e253064ac753ef (patch)
tree3e109d6967d21ba934c8bc6e0d5cca071b09a9b4 /src
parent027b00171c0d92ec669deaa471966e6468c6b8cf (diff)
downloadscala-280c4906d18fd827e2c934af49e253064ac753ef.tar.gz
scala-280c4906d18fd827e2c934af49e253064ac753ef.tar.bz2
scala-280c4906d18fd827e2c934af49e253064ac753ef.zip
prepares our macro defs for refactoring (Step I)
In our codebase we have a bunch of macros, and some of those macros (namely, tag materialization macros and string context "f" formatter) are used inside the compiler itself. The logic of those macros is hardwired into starr's fast track, so it doesn't rely on any of the subsystems of the macro engine to be located, bound and executed. But to trigger this logic we need to color these macros as macros, i.e. as term symbols having the MACRO flag. Currently this works automatically, because fast track macros (the same as regular macros) have their rhs in the "macro ???" form. Having seen the "macro" keyword, the compiler knows that the corresponding def declares a macro and sets the MACRO flag. As the latest refactoring attempt has shown, the "macro" in "macro ???" is unnecessary and might stand in the way of macro refactorings. After all if some symbol is in the fast track registry, then it's definitely a macro. Hence I'm changing the compiler to not need the "macro" keyword in declarations of fast track macros anymore.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala5
2 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
index b0c20f3d0c..5cea86d57d 100644
--- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
@@ -9,6 +9,7 @@ package interpreter
import scala.collection.{ mutable, immutable }
import scala.PartialFunction.cond
import scala.reflect.internal.Chars
+import scala.reflect.internal.Flags._
import language.implicitConversions
trait MemberHandlers {
@@ -126,7 +127,7 @@ trait MemberHandlers {
class DefHandler(member: DefDef) extends MemberDefHandler(member) {
private def vparamss = member.vparamss
- private def isMacro = member.mods.hasFlag(scala.reflect.internal.Flags.MACRO)
+ private def isMacro = member.symbol hasFlag MACRO
// true if not a macro and 0-arity
override def definesValue = !isMacro && flattensToEmpty(vparamss)
override def resultExtractionCode(req: Request) =
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index dc9f07cad9..50d470ccf5 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -983,6 +983,11 @@ trait Namers extends MethodSynthesis {
}
addDefaultGetters(meth, vparamss, tparams, overriddenSymbol)
+ // fast track macros, i.e. macros defined inside the compiler, are hardcoded
+ // hence we make use of that and let them have whatever right-hand side they need
+ // (either "macro ???" as they used to or just "???" to maximally simplify their compilation)
+ if (fastTrack contains ddef.symbol) ddef.symbol setFlag MACRO
+
// macro defs need to be typechecked in advance
// because @macroImpl annotation only gets assigned during typechecking
// otherwise we might find ourselves in the situation when we specified -Xmacro-fallback-classpath