File tree 6 files changed +39
-3
lines changed
compiler/src/dotty/tools/dotc
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 {
62
62
private def nestedScopeCtx (defs : List [Tree ])(implicit ctx : Context ): Context = {
63
63
val nestedCtx = ctx.fresh.setNewScope
64
64
defs foreach {
65
- case d : DefTree => nestedCtx.enter(d.symbol)
65
+ case d : DefTree if d.symbol.isOneOf( GivenOrImplicit ) => nestedCtx.enter(d.symbol)
66
66
case _ =>
67
67
}
68
68
nestedCtx
@@ -73,7 +73,7 @@ class TreeMapWithImplicits extends tpd.TreeMap {
73
73
new TreeTraverser {
74
74
def traverse (tree : Tree )(implicit ctx : Context ): Unit = {
75
75
tree match {
76
- case d : DefTree => nestedCtx.enter(d.symbol)
76
+ case d : DefTree if d.symbol.isOneOf( GivenOrImplicit ) => nestedCtx.enter(d.symbol)
77
77
case _ =>
78
78
}
79
79
traverseChildren(tree)
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
38
38
transform(tree)(ctx.withSource(tree.source))
39
39
else tree match {
40
40
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))
41
45
case _ => checkLevel(super .transform(tree))
42
46
}
43
47
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import dotty.tools.dotc.ast.tpd
19
19
import typer .Implicits .SearchFailureType
20
20
21
21
import scala .collection .mutable
22
- import dotty .tools .dotc .core .Annotations .Annotation
22
+ import dotty .tools .dotc .core .Annotations ._
23
23
import dotty .tools .dotc .core .Names ._
24
24
import dotty .tools .dotc .core .StdNames ._
25
25
import dotty .tools .dotc .core .quoted ._
@@ -407,6 +407,14 @@ class ReifyQuotes extends MacroTransform {
407
407
// TODO move to FirstTransform to trigger even without quotes
408
408
cpy.DefDef (tree)(rhs = defaultValue(tree.rhs.tpe))
409
409
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)
410
418
case _ =>
411
419
super .transform(tree)
412
420
}
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