@@ -23,7 +23,7 @@ import scala.util.control.NonFatal
2323
2424import java .lang .reflect .InvocationTargetException
2525
26- class MacroAnnotations ( thisPhase : DenotTransformer ) :
26+ class MacroAnnotations :
2727 import tpd .*
2828 import MacroAnnotations .*
2929
@@ -82,8 +82,8 @@ class MacroAnnotations(thisPhase: DenotTransformer):
8282 case (prefixed, newTree :: suffixed) =>
8383 allTrees ++= prefixed
8484 insertedAfter = suffixed :: insertedAfter
85- prefixed.foreach(checkAndEnter (_, tree.symbol, annot))
86- suffixed.foreach(checkAndEnter (_, tree.symbol, annot))
85+ prefixed.foreach(checkMacroDef (_, tree.symbol, annot))
86+ suffixed.foreach(checkMacroDef (_, tree.symbol, annot))
8787 newTree
8888 case (Nil , Nil ) =>
8989 report.error(i " Unexpected `Nil` returned by `( ${annot.tree}).transform(..)` during macro expansion " , annot.tree.srcPos)
@@ -118,17 +118,15 @@ class MacroAnnotations(thisPhase: DenotTransformer):
118118 val quotes = QuotesImpl ()(using SpliceScope .contextWithNewSpliceScope(tree.symbol.sourcePos)(using MacroExpansion .context(tree)).withOwner(tree.symbol.owner))
119119 annotInstance.transform(using quotes)(tree.asInstanceOf [quotes.reflect.Definition ])
120120
121- /** Check that this tree can be added by the macro annotation and enter it if needed */
122- private def checkAndEnter (newTree : DefTree , annotated : Symbol , annot : Annotation )(using Context ) =
121+ /** Check that this tree can be added by the macro annotation */
122+ private def checkMacroDef (newTree : DefTree , annotated : Symbol , annot : Annotation )(using Context ) =
123123 val sym = newTree.symbol
124124 if sym.isType && ! sym.isClass then
125125 report.error(i " macro annotation cannot return a `type`. $annot tried to add $sym" , annot.tree)
126126 else if sym.owner != annotated.owner && ! (annotated.owner.isPackageObject && (sym.isClass || sym.is(Module )) && sym.owner == annotated.owner.owner) then
127127 report.error(i " macro annotation $annot added $sym with an inconsistent owner. Expected it to be owned by ${annotated.owner} but was owned by ${sym.owner}. " , annot.tree)
128128 else if annotated.isClass && annotated.owner.is(Package ) /* && !sym.isClass*/ then
129129 report.error(i " macro annotation can not add top-level ${sym.showKind}. $annot tried to add $sym. " , annot.tree)
130- else if ! sym.is(Module ) then // To avoid entering it twice
131- sym.enteredAfter(thisPhase)
132130
133131object MacroAnnotations :
134132
0 commit comments