@@ -23,7 +23,7 @@ import scala.util.control.NonFatal
23
23
24
24
import java .lang .reflect .InvocationTargetException
25
25
26
- class MacroAnnotations ( thisPhase : DenotTransformer ) :
26
+ class MacroAnnotations :
27
27
import tpd .*
28
28
import MacroAnnotations .*
29
29
@@ -82,8 +82,8 @@ class MacroAnnotations(thisPhase: DenotTransformer):
82
82
case (prefixed, newTree :: suffixed) =>
83
83
allTrees ++= prefixed
84
84
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))
87
87
newTree
88
88
case (Nil , Nil ) =>
89
89
report.error(i " Unexpected `Nil` returned by `( ${annot.tree}).transform(..)` during macro expansion " , annot.tree.srcPos)
@@ -118,17 +118,15 @@ class MacroAnnotations(thisPhase: DenotTransformer):
118
118
val quotes = QuotesImpl ()(using SpliceScope .contextWithNewSpliceScope(tree.symbol.sourcePos)(using MacroExpansion .context(tree)).withOwner(tree.symbol.owner))
119
119
annotInstance.transform(using quotes)(tree.asInstanceOf [quotes.reflect.Definition ])
120
120
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 ) =
123
123
val sym = newTree.symbol
124
124
if sym.isType && ! sym.isClass then
125
125
report.error(i " macro annotation cannot return a `type`. $annot tried to add $sym" , annot.tree)
126
126
else if sym.owner != annotated.owner && ! (annotated.owner.isPackageObject && (sym.isClass || sym.is(Module )) && sym.owner == annotated.owner.owner) then
127
127
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)
128
128
else if annotated.isClass && annotated.owner.is(Package ) /* && !sym.isClass*/ then
129
129
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)
132
130
133
131
object MacroAnnotations :
134
132
0 commit comments