@@ -2779,7 +2779,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2779
2779
def isInner (owner : Symbol ) = owner == sym || sym.is(Param ) && owner == sym.owner
2780
2780
val outer = ctx.outersIterator.dropWhile(c => isInner(c.owner)).next()
2781
2781
def local : FreshContext = outer.fresh.setOwner(newLocalDummy(sym.owner))
2782
- sym.owner.infoOrCompleter match
2782
+ val ctx0 = sym.owner.infoOrCompleter match
2783
2783
case completer : Namer # Completer
2784
2784
if sym.is(Param ) && completer.completerTypeParams(sym).nonEmpty =>
2785
2785
// Create a new local context with a dummy owner and a scope containing the
@@ -2788,6 +2788,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2788
2788
local.setScope(newScopeWith(completer.completerTypeParams(sym)* ))
2789
2789
case _ =>
2790
2790
if outer.owner.isClass then local else outer
2791
+ ctx0.addMode(Mode .InAnnotation )
2791
2792
2792
2793
def completeAnnotations (mdef : untpd.MemberDef , sym : Symbol )(using Context ): Unit = {
2793
2794
// necessary to force annotation trees to be computed.
@@ -2802,7 +2803,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2802
2803
}
2803
2804
2804
2805
def typedAnnotation (annot : untpd.Tree )(using Context ): Tree =
2805
- checkAnnotClass(checkAnnotArgs(typed(annot)))
2806
+ val typedAnnot = withMode(Mode .InAnnotation )(typed(annot))
2807
+ checkAnnotClass(checkAnnotArgs(typedAnnot))
2806
2808
2807
2809
def registerNowarn (tree : Tree , mdef : untpd.Tree )(using Context ): Unit =
2808
2810
val annot = Annotations .Annotation (tree)
@@ -3335,7 +3337,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3335
3337
end typedPackageDef
3336
3338
3337
3339
def typedAnnotated (tree : untpd.Annotated , pt : Type )(using Context ): Tree = {
3338
- val annot1 = checkAnnotClass(typedExpr(tree.annot))
3340
+ val annot0 = withMode(Mode .InAnnotation )(typedExpr(tree.annot))
3341
+ val annot1 = checkAnnotClass(annot0)
3339
3342
val annotCls = Annotations .annotClass(annot1)
3340
3343
if annotCls == defn.NowarnAnnot then
3341
3344
registerNowarn(annot1, tree)
0 commit comments