File tree 2 files changed +37
-4
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,19 @@ class Inlining extends MacroTransform {
39
39
40
40
override def checkPostCondition (tree : Tree )(using Context ): Unit =
41
41
tree match {
42
- case tree : RefTree if ! Inliner .inInlineMethod && StagingContext .level == 0 =>
43
- assert(! tree.symbol.isInlineMethod)
42
+ case PackageDef (pid, _) if tree.symbol.owner == defn.RootClass =>
43
+ new TreeTraverser {
44
+ def traverse (tree : Tree )(using Context ): Unit =
45
+ tree match
46
+ case _ : GenericApply if tree.symbol.isQuote =>
47
+ traverseChildren(tree)(using StagingContext .quoteContext)
48
+ case _ : GenericApply if tree.symbol.isExprSplice =>
49
+ traverseChildren(tree)(using StagingContext .spliceContext)
50
+ case tree : RefTree if ! Inliner .inInlineMethod && StagingContext .level == 0 =>
51
+ assert(! tree.symbol.isInlineMethod, tree.show)
52
+ case _ =>
53
+ traverseChildren(tree)
54
+ }.traverse(tree)
44
55
case _ =>
45
56
}
46
57
@@ -57,9 +68,11 @@ class Inlining extends MacroTransform {
57
68
val inlined = Inliner .inlineCall(tree1)
58
69
if tree1 eq inlined then inlined
59
70
else transform(inlined)
60
- case _ : TypeApply if tree.symbol.isQuote =>
71
+ case _ : GenericApply if tree.symbol.isQuote =>
61
72
ctx.compilationUnit.needsStaging = true
62
- super .transform(tree)
73
+ super .transform(tree)(using StagingContext .quoteContext)
74
+ case _ : GenericApply if tree.symbol.isExprSplice =>
75
+ super .transform(tree)(using StagingContext .spliceContext)
63
76
case _ =>
64
77
super .transform(tree)
65
78
Original file line number Diff line number Diff line change
1
+
2
+ import scala .quoted ._
3
+ import scala .quoted .staging ._
4
+
5
+ object Test {
6
+
7
+ given Toolbox = Toolbox .make(getClass.getClassLoader)
8
+
9
+ def main (args : Array [String ]): Unit = run {
10
+ ' {
11
+ def m (using Quotes ) = ' {
12
+ errorOnceInlined() // Should not be inlined while `run` is executed. It would be inlined in the next stage.
13
+ }
14
+ ()
15
+ }
16
+ }
17
+
18
+ inline def errorOnceInlined () = compiletime.error(" Error" )
19
+
20
+ }
You can’t perform that action at this time.
0 commit comments