Skip to content

-coverage-out outputs incompatible line numbers #18916

@tarao

Description

@tarao

Compiler version

3.3.1

Minimized code

https://gist.github.com/tarao/43d2c4263478c91ae3d5e21f314a7e13

Output

...
0
A.scala
<empty>
A$
Object
<empty>.A$
hello
37
53
2
println
...

Expectation

...
0
A.scala
<empty>
A$
Object
<empty>.A$
hello
37
53
3
println
...

Note

Output in Scala 2.13.12 looks like this:

...
1
A.scala
<empty>
A
Object
A
hello
37
53
3
scala.Predef.println
...
  • in Scala 2.13.12 : line number starts from 1
  • in Scala 3.3.1 : line number starts from 0

The incompatibility breaks highlighting using cobertura.xml (which relies on line numbers not offsets) for example on Codecov.

I guess we need + 1 here?

https://github.com/lampepfl/dotty/blob/721e7c87ee95b811984b7b992728729d7094c4c4/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala#L100

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coverageCode coverage, see https://dotty.epfl.ch/docs/internals/coverage.htmlitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions