From ffc2389840852a120fecd772206d55db9a79f30e Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sun, 5 Feb 2012 16:49:18 +0100 Subject: Replaced LiftCode with a function in MacroContext Major cleanup of reification: * LiftCode phase has been removed * Code has been deprecated and will be removed as we roll a new starr * Logic related to type-directed lifting has been purged scala.reflect.macro.Context#reify now provides the same services as LiftCode provided (except that it returns Tree, not Code). For testing purposes, I've retained the oh-so-convenient automagic lift. test/files/codelib/code.jar now hosts Code.lift reimplemented in a macro, so that the tests can continue working as if nothing has happened. --- test/files/codelib/code.jar.desired.sha1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/files/codelib/code.jar.desired.sha1 (limited to 'test/files/codelib/code.jar.desired.sha1') diff --git a/test/files/codelib/code.jar.desired.sha1 b/test/files/codelib/code.jar.desired.sha1 new file mode 100644 index 0000000000..5e7acf3b90 --- /dev/null +++ b/test/files/codelib/code.jar.desired.sha1 @@ -0,0 +1 @@ +5880dd44ee9fedec44fed3f223842e42d8a63959 ?code.jar -- cgit v1.2.3 From 2fc92eb4f0ab8f12b4ed6c2439ef9a53484b3e45 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 9 Feb 2012 19:24:00 +0100 Subject: Fixes https://issues.scala-lang.org/browse/SI-5453 Originally we thought that macros declared inside objects should not provide _this to their bodies. However, it: 1) contradicts vanilla Scala rules, according to which both class and object methods can use this, 2) imposes unnecessary burden on macro developers without providing any conveniences to us. Review by @odersky. --- src/compiler/scala/tools/nsc/typechecker/Macros.scala | 8 ++------ test/files/codelib/code.jar.desired.sha1 | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'test/files/codelib/code.jar.desired.sha1') diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index ed249796a8..470f3e7117 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -20,15 +20,12 @@ trait Macros { self: Analyzer => macroArgs(fn) :+ args case TypeApply(fn, args) => macroArgs(fn) :+ args - case Select(qual, name) if !isStaticMacro(tree.symbol) => + case Select(qual, name) => List(List(qual)) case _ => List(List()) } - private def isStaticMacro(mac: Symbol): Boolean = - mac.owner.isModuleClass - /** * The definition of the method implementing a macro. Example: * Say we have in a class C @@ -46,7 +43,6 @@ trait Macros { self: Analyzer => * expr * } * - * If `foo` is declared in an object, the second parameter list is () instead of (_this: _context.Tree). * If macro has no type arguments, the third parameter list is omitted (it's not empty, but omitted altogether). * * To find out the desugared representation of your particular macro, compile it with -Ymacro-debug. @@ -58,7 +54,7 @@ trait Macros { self: Analyzer => def globSelect(name: Name) = Select(Ident(nme.macroContext), name) def globTree = globSelect(tpnme.Tree) def globTypeTree = globSelect(tpnme.TypeTree) - val thisParamSec = if (isStaticMacro(mdef.symbol)) List() else List(paramDef(nme.macroThis, globTree)) + val thisParamSec = List(paramDef(newTermName(nme.macroThis), globTree)) def tparamInMacro(tdef: TypeDef) = paramDef(tdef.name.toTermName, globTypeTree) def vparamInMacro(vdef: ValDef): ValDef = paramDef(vdef.name, vdef.tpt match { case tpt @ AppliedTypeTree(hk, _) if treeInfo.isRepeatedParamType(tpt) => AppliedTypeTree(hk, List(globTree)) diff --git a/test/files/codelib/code.jar.desired.sha1 b/test/files/codelib/code.jar.desired.sha1 index 5e7acf3b90..dbf19cafd7 100644 --- a/test/files/codelib/code.jar.desired.sha1 +++ b/test/files/codelib/code.jar.desired.sha1 @@ -1 +1 @@ -5880dd44ee9fedec44fed3f223842e42d8a63959 ?code.jar +e25f1daf9010b9dc6038ae7069fc9d0f7d48a53b ?code.jar -- cgit v1.2.3