From e1d79a280c16083db309be02f911e326ef205f2c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 1 Dec 2016 14:01:37 +0100 Subject: Address reviewers comments --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 4 ++-- compiler/src/dotty/tools/dotc/typer/Typer.scala | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/typer') diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 9b6bad291..b8fe46745 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -570,10 +570,10 @@ class Namer { typer: Typer => * that are already added to the symbol. */ def addAnnotations(sym: Symbol, stat: MemberDef)(implicit ctx: Context) = { - // (1) The context in which an annotation of a top-evel class or module is evaluated + // (1) The context in which an annotation of a top-level class or module is evaluated // is the closest enclosing context which has the enclosing package as owner. // (2) The context in which an annotation for any other symbol is evaluated is the - // closest enclosing context which has the owner of the class enclpsing the symbol as owner. + // closest enclosing context which has the owner of the class enclosing the symbol as owner. // E.g in // // package p diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 263ebacd7..4ec1c460f 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1138,7 +1138,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit lazy val annotCtx = { val c = ctx.outersIterator.dropWhile(_.owner == sym).next c.property(ExprOwner) match { - case Some(exprOwner) if c.owner.isClass => c.exprContext(mdef, exprOwner) + case Some(exprOwner) if c.owner.isClass => + // We need to evaluate annotation arguments in an expression context, since + // classes defined in a such arguments should not be entered into the + // enclosing class. + c.exprContext(mdef, exprOwner) case None => c } } -- cgit v1.2.3