File tree 2 files changed +7
-3
lines changed
compiler/src/dotty/tools/dotc/typer 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -570,10 +570,10 @@ class Namer { typer: Typer =>
570
570
* that are already added to the symbol.
571
571
*/
572
572
def addAnnotations (sym : Symbol , stat : MemberDef )(implicit ctx : Context ) = {
573
- // (1) The context in which an annotation of a top-evel class or module is evaluated
573
+ // (1) The context in which an annotation of a top-level class or module is evaluated
574
574
// is the closest enclosing context which has the enclosing package as owner.
575
575
// (2) The context in which an annotation for any other symbol is evaluated is the
576
- // closest enclosing context which has the owner of the class enclpsing the symbol as owner.
576
+ // closest enclosing context which has the owner of the class enclosing the symbol as owner.
577
577
// E.g in
578
578
//
579
579
// package p
Original file line number Diff line number Diff line change @@ -1138,7 +1138,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1138
1138
lazy val annotCtx = {
1139
1139
val c = ctx.outersIterator.dropWhile(_.owner == sym).next
1140
1140
c.property(ExprOwner ) match {
1141
- case Some (exprOwner) if c.owner.isClass => c.exprContext(mdef, exprOwner)
1141
+ case Some (exprOwner) if c.owner.isClass =>
1142
+ // We need to evaluate annotation arguments in an expression context, since
1143
+ // classes defined in a such arguments should not be entered into the
1144
+ // enclosing class.
1145
+ c.exprContext(mdef, exprOwner)
1142
1146
case None => c
1143
1147
}
1144
1148
}
You can’t perform that action at this time.
0 commit comments