Skip to content

Commit 0954a07

Browse files
authored
Merge pull request #8434 from tgodzik/fix-off-by-one
Add +1 to zinc positions in the compiler bridge
2 parents b9ce031 + 12c8e1f commit 0954a07

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

sbt-bridge/src/xsbt/DelegatingReporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public Optional<String> sourcePath() {
8888
else return Optional.ofNullable(src.file().path());
8989
}
9090
public Optional<Integer> line() {
91-
int line = pos.line();
91+
int line = pos.line() + 1;
9292
if (line == -1) return Optional.empty();
9393
else return Optional.of(line);
9494
}

sbt-dotty/sbt-test/compilerReporter/simple/project/Reporter.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@ object Reporter {
2929
println(problems.toList)
3030
assert(problems.size == 1)
3131

32-
// Assert disabled because we don't currently pass positions to sbt
33-
// See https://github.com/lampepfl/dotty/pull/2107
34-
// assert(problems.forall(_.position.offset.isDefined))
32+
// make sure position reported by zinc are proper
33+
val mainProblem = problems.head
34+
35+
val line = mainProblem.position().line()
36+
assert(line.isPresent() == true)
37+
assert(line.get() == 9)
38+
39+
val pointer = mainProblem.position().pointer()
40+
assert(pointer.isPresent() == true)
41+
assert(pointer.get() == 10)
42+
43+
assert(problems.forall(_.position.offset.isPresent))
3544

3645
assert(problems.count(_.severity == Severity.Error) == 1) // not found: er1,
3746
}).value

0 commit comments

Comments
 (0)