Skip to content

Commit 767e24e

Browse files
committed
Only track inlined positions
1 parent 3be62c1 commit 767e24e

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import typer.ProtoTypes
77
import transform.SymUtils._
88
import transform.TypeUtils._
99
import core._
10-
import util.Spans._, Types._, Contexts._, Constants._, Names._, Flags._, NameOps._
10+
import util.Spans._, util.SourcePosition, Types._, Contexts._, Constants._, Names._, Flags._, NameOps._
1111
import Symbols._, StdNames._, Annotations._, Trees._, Symbols._
1212
import Decorators._, DenotTransformers._
1313
import collection.{immutable, mutable}
@@ -1232,7 +1232,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12321232
}
12331233

12341234
/** A key to be used in a context property that tracks enclosing inlined calls */
1235-
private val InlinedCalls = Property.Key[List[Tree]]()
1235+
private val InlinedCalls = Property.Key[List[SourcePosition]]()
12361236

12371237
/** A key to be used in a context property that tracks the number of inlined trees */
12381238
private val InlinedTrees = Property.Key[Counter]()
@@ -1254,15 +1254,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12541254
case t1 :: ts2 => ts2
12551255
case _ => oldIC
12561256
else
1257-
call :: oldIC
1257+
call.sourcePos :: oldIC
12581258

12591259
val ctx1 = ctx.fresh.setProperty(InlinedCalls, newIC)
12601260
if oldIC.isEmpty then ctx1.setProperty(InlinedTrees, new Counter) else ctx1
12611261
}
12621262

12631263
/** All enclosing calls that are currently inlined, from innermost to outermost.
12641264
*/
1265-
def enclosingInlineds(using Context): List[Tree] =
1265+
def enclosingInlineds(using Context): List[SourcePosition] =
12661266
ctx.property(InlinedCalls).getOrElse(Nil)
12671267

12681268
/** Record inlined trees */

compiler/src/dotty/tools/dotc/quoted/MacroExpansion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object MacroExpansion {
1313
def position(using Context): Option[SourcePosition] =
1414
ctx.property(MacroExpansionPosition)
1515

16-
def context(inlinedFrom: tpd.Tree)(using Context): Context =
16+
def context(inlinedFrom: SourcePosition)(using Context): Context =
1717
ctx.fresh.setProperty(MacroExpansionPosition, SourcePosition(inlinedFrom.source, inlinedFrom.span)).setTypeAssigner(new Typer).withSource(inlinedFrom.source)
1818
}
1919

compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object QuoteContextImpl {
2626
new QuoteContextImpl(ctx)
2727

2828
def showTree(tree: tpd.Tree)(using Context): String = {
29-
val qctx = QuoteContextImpl()(using MacroExpansion.context(tree))
29+
val qctx = QuoteContextImpl()(using MacroExpansion.context(tree.sourcePos))
3030
val syntaxHighlight =
3131
if (ctx.settings.color.value == "always") SyntaxHighlight.ANSI
3232
else SyntaxHighlight.plain

compiler/src/dotty/tools/dotc/report.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ object report:
115115
if (ctx.settings.Ydebug.value) warning(msg, pos)
116116

117117
private def addInlineds(pos: SrcPos)(using Context): SourcePosition =
118-
def recur(pos: SourcePosition, inlineds: List[Trees.Tree[?]]): SourcePosition = inlineds match
118+
def recur(pos: SourcePosition, inlineds: List[SourcePosition]): SourcePosition = inlineds match
119119
case inlined :: inlineds1 => pos.withOuter(recur(inlined.sourcePos, inlineds1))
120120
case Nil => pos
121121
recur(pos.sourcePos, tpd.enclosingInlineds)

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object Inliner {
132132
i"""|Maximal number of $reason (${setting.value}) exceeded,
133133
|Maybe this is caused by a recursive inline method?
134134
|You can use ${setting.name} to change the limit.""",
135-
(tree :: enclosingInlineds).last.srcPos
135+
(tree :: enclosingInlineds).last
136136
)
137137
tree2
138138
}
@@ -724,7 +724,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
724724
val callToReport = if (enclosingInlineds.nonEmpty) enclosingInlineds.last else call
725725
val ctxToReport = ctx.outersIterator.dropWhile(enclosingInlineds(using _).nonEmpty).next
726726
inContext(ctxToReport) {
727-
report.error(message, callToReport.srcPos)
727+
report.error(message, callToReport)
728728
}
729729
case _ =>
730730
}
@@ -1432,7 +1432,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
14321432
ctx.compilationUnit.suspend() // this throws a SuspendException
14331433

14341434
val evaluatedSplice = inContext(quoted.MacroExpansion.context(inlinedFrom)) {
1435-
Splicer.splice(body, inlinedFrom.srcPos, MacroClassLoader.fromContext)
1435+
Splicer.splice(body, inlinedFrom, MacroClassLoader.fromContext)
14361436
}
14371437
val inlinedNormailizer = new TreeMap {
14381438
override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match {

0 commit comments

Comments
 (0)