Skip to content

Backend line-number computation doesn't account for underlying SourceFiles. #21762

Closed
@bishabosha

Description

@bishabosha

Compiler version

3.5.1

Minimized code

The backend computes lines in the classfile by comparing the point offset to the source file of the current compilation unit.

This is problematic for code where the source file is derived from user code, i.e. with code-gen surrounding it.

The backend should at least be using the source file of the position, not the compilation unit, to compute the linenumber from offset, and ideally it should allow to hook-in customisations that allow for corrections such as "positionInUltimateSource"

here is the relevant line in BCodeSkelBuilder.
https://github.com/dotty-staging/dotty/blob/07f729e4322be097d54d4092420806ccf36b5f05/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala#L625-L626

Expectation

Follow Scala 2, which does this

see https://github.com/scala/scala/blame/ceda7ea5a42168eacf4fe9b70f6e08e1684bbfda/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala#L498

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions