@@ -207,23 +207,36 @@ else
207207 function linetable_scopes (m:: Method )
208208 src = Base. uncompressed_ast (m)
209209 lt, cl = src. linetable, src. codelocs
210- return [iszero (cl[pc]) ? Core. LineInfoNode[] : [lt[cl[pc]]] for pc = eachindex (cl)]
210+ lts = [Vector {Core.LineInfoNode} () for _ = eachindex (src. code)]
211+ for pc = eachindex (src. code)
212+ iszero (cl[pc]) && continue
213+ scope = lts[pc]
214+ push! (scope, lt[cl[pc]])
215+ while (k = last (scope). inlined_at) != Int32 (0 )
216+ push! (scope, lt[k])
217+ end
218+ if length (scope) > 1
219+ reverse! (scope)
220+ end
221+ end
222+ return lts
211223 end
212224end
213225@doc """
214226 scopes = linetable_scopes(m::Method)
215227
216- Return an array of "scopes" for each statement in the lowered code for `m`.
217- If `src = Base.uncompressed_ast(m)`, then `scopes[pc]` is an vector of `LineInfoNode`
218- objects that represent the scopes active at the statement at position `pc` in `src.code`.
228+ Return an array of "scopes" for each statement in the lowered code for `m`. If
229+ `src = Base.uncompressed_ast(m)`, then `scopes[pc]` is an vector of
230+ `LineInfoNode` objects that represent the scopes active at the statement at
231+ position `pc` in `src.code`.
219232
220- On Julia 1.12 and later, `scopes[pc]` may have length larger than 1, where the first entry
221- is for the source location in `m`, and any later entries reflect code from inlining.
222- It will be a vector of `Base.Compiler.IRShow.LineInfoNode` objects.
233+ `scopes[pc]` may have length larger than 1, where the first entry is for the
234+ source location in `m`, and any later entries reflect code from inlining.
223235
224- Prior to Julia 1.12, `scopes[pc]` will have length 1, and will be a vector of `Core.LineInfoNode`
225- objects (which have more fields than `Base.Compiler.IRShow.LineInfoNode`). It will represent
226- the final stage of inlining for the statement at position `pc` in `src.code`.
236+ The precise type of these entries varies with Julia version,
237+ `Base.Compiler.IRShow.LineInfoNode` objects on Julia 1.12 and up, and
238+ `Core.LineInfoNode` objects on earlier versions. These objects differ in some of
239+ their fields. `:method`, `:file`, and `:line` are common to both types.
227240""" linetable_scopes
228241
229242getmethod (m:: Method ) = m
0 commit comments