File tree Expand file tree Collapse file tree 6 files changed +39
-3
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 6 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ class TreeMapWithImplicits extends tpd.TreeMap {
6262 private def nestedScopeCtx (defs : List [Tree ])(implicit ctx : Context ): Context = {
6363 val nestedCtx = ctx.fresh.setNewScope
6464 defs foreach {
65- case d : DefTree => nestedCtx.enter(d.symbol)
65+ case d : DefTree if d.symbol.isOneOf( GivenOrImplicit ) => nestedCtx.enter(d.symbol)
6666 case _ =>
6767 }
6868 nestedCtx
@@ -73,7 +73,7 @@ class TreeMapWithImplicits extends tpd.TreeMap {
7373 new TreeTraverser {
7474 def traverse (tree : Tree )(implicit ctx : Context ): Unit = {
7575 tree match {
76- case d : DefTree => nestedCtx.enter(d.symbol)
76+ case d : DefTree if d.symbol.isOneOf( GivenOrImplicit ) => nestedCtx.enter(d.symbol)
7777 case _ =>
7878 }
7979 traverseChildren(tree)
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
3838 transform(tree)(ctx.withSource(tree.source))
3939 else tree match {
4040 case tree : DefDef if tree.symbol.is(Inline ) && level > 0 => EmptyTree
41+ case tree : DefTree =>
42+ for (annot <- tree.symbol.annotations)
43+ transform(annot.tree) given ctx .withOwner(tree.symbol)
44+ checkLevel(super .transform(tree))
4145 case _ => checkLevel(super .transform(tree))
4246 }
4347 }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import dotty.tools.dotc.ast.tpd
1919import typer .Implicits .SearchFailureType
2020
2121import scala .collection .mutable
22- import dotty .tools .dotc .core .Annotations .Annotation
22+ import dotty .tools .dotc .core .Annotations ._
2323import dotty .tools .dotc .core .Names ._
2424import dotty .tools .dotc .core .StdNames ._
2525import dotty .tools .dotc .core .quoted ._
@@ -407,6 +407,14 @@ class ReifyQuotes extends MacroTransform {
407407 // TODO move to FirstTransform to trigger even without quotes
408408 cpy.DefDef (tree)(rhs = defaultValue(tree.rhs.tpe))
409409
410+ case tree : DefTree if level >= 1 =>
411+ val newAnnotations = tree.symbol.annotations.mapconserve { annot =>
412+ val newAnnotTree = transform(annot.tree) given ctx .withOwner(tree.symbol)
413+ if (annot.tree == newAnnotTree) annot
414+ else ConcreteAnnotation (newAnnotTree)
415+ }
416+ tree.symbol.annotations = newAnnotations
417+ super .transform(tree)
410418 case _ =>
411419 super .transform(tree)
412420 }
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+ class Test {
3+ def foo (str : String ) given QuoteContext = ' {
4+ @ deprecated(str, " " ) // error
5+ def bar = ???
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+ class Test {
3+ def foo (str : String ) given QuoteContext = ' {
4+ delegate for QuoteContext = ???
5+ ' {
6+ @ deprecated(str, " " ) // error
7+ def bar = ???
8+ }
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+ class Test {
3+ def foo (str : Expr [String ]) given QuoteContext = ' {
4+ @ deprecated($str, " " )
5+ def bar = ???
6+ }
7+ }
You can’t perform that action at this time.
0 commit comments