@@ -89,9 +89,9 @@ object InlinedSourceMaps:
89
89
class RequestCollector (enclosingFile : SourceFile ) extends TreeTraverser :
90
90
override def traverse (tree : Tree )(using Context ): Unit =
91
91
tree match
92
- case Inlined (call, bindings, expansion) =>
92
+ case inlined @ Inlined (call, bindings, expansion) =>
93
93
if expansion.source != enclosingFile && expansion.source != cunit.source then
94
- requests += tree. asInstanceOf [ Inlined ]
94
+ requests += inlined
95
95
val topLevelClass = Option .when(! call.isEmpty)(call.symbol.topLevelClass)
96
96
97
97
topLevelClass match
@@ -131,23 +131,15 @@ object InlinedSourceMaps:
131
131
132
132
def debugExtension : Option [String ] = Some (" TODO" )
133
133
134
- private val inlines = mutable.ListBuffer .empty[Inlined ]
135
-
136
134
def lineFor (tree : Tree ): Option [Int ] =
137
135
138
- tree match
139
- case Inlined (call, binding, expansion) =>
140
- inlines += tree.asInstanceOf [Inlined ]
141
- None
142
- case _ =>
143
- val sourcePos = tree.sourcePos
144
- val inline = inlines.findLast(_.expansion.contains(tree))
145
- requests.findLast(r => r.inline .expansion.contains(tree)) match
146
- case Some (request) =>
147
- val offset = sourcePos.startLine - request.inline.expansion.sourcePos.startLine
148
- val virtualLine = request.firstFakeLine + offset
149
- if requests.filter(_.inline.expansion.contains(tree)).size > 1 then None
150
- else Some (virtualLine + 1 ) // + 1 because the first line is 1 in the LineNumberTable
151
- case None =>
152
- // report.warning(s"${sourcePos.show} was inlined in ${cunit.source} but its inlining position was not recorded.")
153
- None
136
+ val sourcePos = tree.sourcePos
137
+ requests.findLast(r => r.inline .expansion.contains(tree)) match
138
+ case Some (request) =>
139
+ val offset = sourcePos.startLine - request.inline.expansion.sourcePos.startLine
140
+ val virtualLine = request.firstFakeLine + offset
141
+ if requests.filter(_.inline.expansion.contains(tree)).size > 1 then None
142
+ else Some (virtualLine + 1 ) // + 1 because the first line is 1 in the LineNumberTable
143
+ case None =>
144
+ // report.warning(s"${sourcePos.show} was inlined in ${cunit.source} but its inlining position was not recorded.")
145
+ None
0 commit comments