Skip to content

Commit e1d79a2

Browse files
committed
Address reviewers comments
1 parent 9a3f82c commit e1d79a2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,10 @@ class Namer { typer: Typer =>
570570
* that are already added to the symbol.
571571
*/
572572
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
574574
// is the closest enclosing context which has the enclosing package as owner.
575575
// (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.
577577
// E.g in
578578
//
579579
// package p

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
11381138
lazy val annotCtx = {
11391139
val c = ctx.outersIterator.dropWhile(_.owner == sym).next
11401140
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)
11421146
case None => c
11431147
}
11441148
}

0 commit comments

Comments
 (0)