Skip to content

Commit e1528e5

Browse files
committed
Add +1 to zinc positions in the compiler bridge
1 parent 0404238 commit e1528e5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ object Reporter {
2929
println(problems.toList)
3030
assert(problems.size == 1)
3131

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

0 commit comments

Comments
 (0)