@@ -23,7 +23,7 @@ import util.Spans.Span
2323import dotty .tools .dotc .transform .Splicer
2424import dotty .tools .dotc .transform .BetaReduce
2525import quoted .QuoteUtils
26- import staging .StagingLevel
26+ import staging .StagingLevel .{ level , spliceContext }
2727import scala .annotation .constructorOnly
2828
2929/** General support for inlining */
@@ -834,9 +834,7 @@ class Inliner(val call: tpd.Tree)(using Context):
834834
835835 override def typedSplice (tree : untpd.Splice , pt : Type )(using Context ): Tree =
836836 super .typedSplice(tree, pt) match
837- case tree1 @ Splice (expr)
838- if StagingLevel .level == 0
839- && ! hasInliningErrors =>
837+ case tree1 @ Splice (expr) if level == 0 && ! hasInliningErrors =>
840838 val expanded = expandMacro(expr, tree1.srcPos)
841839 transform.TreeChecker .checkMacroGeneratedTree(tree1, expanded)
842840 typedExpr(expanded) // Inline calls and constant fold code generated by the macro
@@ -1032,9 +1030,9 @@ class Inliner(val call: tpd.Tree)(using Context):
10321030 }
10331031
10341032 private def expandMacro (body : Tree , splicePos : SrcPos )(using Context ) = {
1035- assert(StagingLevel . level == 0 )
1033+ assert(level == 0 )
10361034 val inlinedFrom = enclosingInlineds.last
1037- val dependencies = macroDependencies(body)
1035+ val dependencies = macroDependencies(body)( using spliceContext)
10381036 val suspendable = ctx.compilationUnit.isSuspendable
10391037 if dependencies.nonEmpty && ! ctx.reporter.errorsReported then
10401038 for sym <- dependencies do
@@ -1064,32 +1062,12 @@ class Inliner(val call: tpd.Tree)(using Context):
10641062 */
10651063 private def macroDependencies (tree : Tree )(using Context ) =
10661064 new TreeAccumulator [List [Symbol ]] {
1067- private var level = - 1
10681065 override def apply (syms : List [Symbol ], tree : tpd.Tree )(using Context ): List [Symbol ] =
1069- if level != - 1 then foldOver(syms, tree)
1070- else tree match {
1071- case tree : RefTree if tree.isTerm && tree.symbol.isDefinedInCurrentRun && ! tree.symbol.isLocal =>
1066+ tree match {
1067+ case tree : RefTree if tree.isTerm && level == - 1 && tree.symbol.isDefinedInCurrentRun && ! tree.symbol.isLocal =>
10721068 foldOver(tree.symbol :: syms, tree)
1073- case Quote (body) =>
1074- level += 1
1075- try apply(syms, body)
1076- finally level -= 1
1077- case QuotedTypeOf (body) =>
1078- level += 1
1079- try apply(syms, body)
1080- finally level -= 1
1081- case Splice (body) =>
1082- level -= 1
1083- try apply(syms, body)
1084- finally level += 1
1085- case SplicedType (body) =>
1086- level -= 1
1087- try apply(syms, body)
1088- finally level += 1
1089- case _ : TypTree =>
1090- syms
1091- case _ =>
1092- foldOver(syms, tree)
1069+ case _ : TypTree => syms
1070+ case _ => foldOver(syms, tree)
10931071 }
10941072 }.apply(Nil , tree)
10951073end Inliner
0 commit comments