You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: scoverage statement's line number should be 1-base
fix#18916
This PR makes scoverage statements' line number 1-base,
instead of 0-base, as @tarao described.
It would be ideal if we could find specifications of many of
coverage report fomats (such as Jacoco XML, cobertura.xml, lcov.txt...)
and confirm most of them expect the line numbers 1-base.
However, it seems there's no formal specification for them AFAIK.
Since we've been using 1-base so far in Scala2 and it hasn't been a problem,
so I guess it's OK to change to 1-base (and most of coverage report
format and visualizer expect 1-base maybe).
I believe it should be reporter / aggregator's responsibility to
adjust the line numbers if some coverage format expects 0-base.
Copy file name to clipboardExpand all lines: compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,9 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
97
97
id = id,
98
98
start = pos.start,
99
99
end = pos.end,
100
-
line = pos.line,
100
+
// +1 to account for the line number starting at 1
101
+
// the internal line number is 0-base https://github.com/lampepfl/dotty/blob/18ada516a85532524a39a962b2ddecb243c65376/compiler/src/dotty/tools/dotc/util/SourceFile.scala#L173-L176
0 commit comments