@@ -92,11 +92,12 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
9292 methName : String ,
9393 // flattens the macro impl's parameter lists having symbols replaced with their fingerprints
9494 // currently fingerprints are calculated solely from types of the symbols:
95- // * c.Expr[T] => IMPLPARAM_EXPR
96- // * c.WeakTypeTag[T] => index of the type parameter corresponding to that type tag
97- // * everything else (e.g. scala.reflect.macros.Context) => IMPLPARAM_OTHER
95+ // * c.Expr[T] => LiftedTyped
96+ // * c.Tree => LiftedUntyped
97+ // * c.WeakTypeTag[T] => Tagged(index of the type parameter corresponding to that type tag)
98+ // * everything else (e.g. scala.reflect.macros.Context) => Other
9899 // f.ex. for: def impl[T: WeakTypeTag, U, V: WeakTypeTag](c: Context)(x: c.Expr[T], y: c.Tree): (U, V) = ???
99- // `signature` will be equal to List(List(Other), List(Lifted, Other ), List(Tagged(0), Tagged(2)))
100+ // `signature` will be equal to List(List(Other), List(LiftedTyped, LiftedUntyped ), List(Tagged(0), Tagged(2)))
100101 signature : List [List [Fingerprint ]],
101102 // type arguments part of a macro impl ref (the right-hand side of a macro definition)
102103 // these trees don't refer to a macro impl, so we can pickle them as is
@@ -124,7 +125,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
124125 * "className" = "Macros$"))
125126 */
126127 object MacroImplBinding {
127- val versionFormat = 4 .0
128+ val versionFormat = 5 .0
128129
129130 def pickleAtom (obj : Any ): Tree =
130131 obj match {
@@ -164,7 +165,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
164165 def signature : List [List [Fingerprint ]] = {
165166 def fingerprint (tpe : Type ): Fingerprint = tpe.dealiasWiden match {
166167 case TypeRef (_, RepeatedParamClass , underlying :: Nil ) => fingerprint(underlying)
167- case ExprClassOf (_) => Lifted
168+ case ExprClassOf (_) => LiftedTyped
169+ case TreeType () => LiftedUntyped
168170 case _ => Other
169171 }
170172
@@ -388,7 +390,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
388390 val wrappedArgs = mapWithIndex(args)((arg, j) => {
389391 val fingerprint = implParams(min(j, implParams.length - 1 ))
390392 fingerprint match {
391- case Lifted => context.Expr [Nothing ](arg)(TypeTag .Nothing ) // TODO: SI-5752
393+ case LiftedTyped => context.Expr [Nothing ](arg)(TypeTag .Nothing ) // TODO: SI-5752
394+ case LiftedUntyped => arg
392395 case _ => abort(s " unexpected fingerprint $fingerprint in $binding with paramss being $paramss " +
393396 s " corresponding to arg $arg in $argss" )
394397 }
@@ -690,6 +693,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
690693 }
691694 expanded match {
692695 case expanded : Expr [_] if expandee.symbol.isTermMacro => validateResultingTree(expanded.tree)
696+ case expanded : Tree if expandee.symbol.isTermMacro => validateResultingTree(expanded)
693697 case _ => MacroExpansionHasInvalidTypeError (expandee, expanded)
694698 }
695699 } catch {
@@ -804,16 +808,19 @@ class Fingerprint(val value: Int) extends AnyVal {
804808 def paramPos = { assert(isTag, this ); value }
805809 def isTag = value >= 0
806810 def isOther = this == Other
807- def isExpr = this == Lifted
811+ def isExpr = this == LiftedTyped
812+ def isTree = this == LiftedUntyped
808813 override def toString = this match {
809814 case Other => " Other"
810- case Lifted => " Expr"
815+ case LiftedTyped => " Expr"
816+ case LiftedUntyped => " Tree"
811817 case _ => s " Tag( $value) "
812818 }
813819}
814820
815821object Fingerprint {
816822 def Tagged (tparamPos : Int ) = new Fingerprint (tparamPos)
817823 val Other = new Fingerprint (- 1 )
818- val Lifted = new Fingerprint (- 2 )
824+ val LiftedTyped = new Fingerprint (- 2 )
825+ val LiftedUntyped = new Fingerprint (- 3 )
819826}
0 commit comments