diff --git a/sbt-bridge/src/xsbt/DelegatingReporter.java b/sbt-bridge/src/xsbt/DelegatingReporter.java index 0f533a0e0d9a..59fd5464bd61 100644 --- a/sbt-bridge/src/xsbt/DelegatingReporter.java +++ b/sbt-bridge/src/xsbt/DelegatingReporter.java @@ -88,7 +88,7 @@ public Optional sourcePath() { else return Optional.ofNullable(src.file().path()); } public Optional line() { - int line = pos.line(); + int line = pos.line() + 1; if (line == -1) return Optional.empty(); else return Optional.of(line); } diff --git a/sbt-dotty/sbt-test/compilerReporter/simple/project/Reporter.scala b/sbt-dotty/sbt-test/compilerReporter/simple/project/Reporter.scala index 1d72caa02cab..46e042cb08b4 100644 --- a/sbt-dotty/sbt-test/compilerReporter/simple/project/Reporter.scala +++ b/sbt-dotty/sbt-test/compilerReporter/simple/project/Reporter.scala @@ -29,9 +29,18 @@ object Reporter { println(problems.toList) assert(problems.size == 1) - // Assert disabled because we don't currently pass positions to sbt - // See https://github.com/lampepfl/dotty/pull/2107 - // assert(problems.forall(_.position.offset.isDefined)) + // make sure position reported by zinc are proper + val mainProblem = problems.head + + val line = mainProblem.position().line() + assert(line.isPresent() == true) + assert(line.get() == 9) + + val pointer = mainProblem.position().pointer() + assert(pointer.isPresent() == true) + assert(pointer.get() == 10) + + assert(problems.forall(_.position.offset.isPresent)) assert(problems.count(_.severity == Severity.Error) == 1) // not found: er1, }).value