From dc1c8a019a23ea1ffab9e5d7c4fd53859a07ee36 Mon Sep 17 00:00:00 2001 From: Markus Sutter Date: Fri, 4 Jun 2021 08:18:18 +0200 Subject: [PATCH 1/3] Add person readable toString for PositionBridge There are compile call paths relying on meaningful toString impl. for error/warning log messages. Therefor lets add toString, which is: "concise but informative representation that is easy for a person to read." Without this, e.g. users of https://github.com/davidB/scala-maven-plugin get unsuitable compile problems like: [Warn] dotty.tools.xsbt.PositionBridge@4fbdc20: match may not be exhaustive.... Example call path: log:45, SbtLogger (sbt_inc) log:47, Logger (sbt.util) warn:43, Logger (sbt.util) logWarning:159, LoggedReporter (sbt.internal.inc) display:168, LoggedReporter (sbt.internal.inc) log:142, LoggedReporter (sbt.internal.inc) doReport:43, DelegatingReporter (dotty.tools.xsbt) report:150, Reporter (dotty.tools.dotc.reporting) issueWarning:32, report$ (dotty.tools.dotc) warning:67, report$ (dotty.tools.dotc) checkExhaustivity:847, SpaceEngine (dotty.tools.dotc.transform.patmat) .... --- sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java b/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java index 2f20609578db..376ec6b361cb 100644 --- a/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java +++ b/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java @@ -39,6 +39,10 @@ public Optional pointer() { public Optional pointerSpace() { return Optional.empty(); } + + public String toString() { + return ""; + } }; public PositionBridge(SourcePosition pos, SourceFile src) { @@ -116,4 +120,9 @@ public Optional pointerSpace() { result.append(lineContent.charAt(i) == '\t' ? '\t' : ' '); return Optional.of(result.toString()); } + + @Override + public String toString() { + return pos.toString(); + } } From 2d01ba24720b6493ab3cc31f182b8456697d1219 Mon Sep 17 00:00:00 2001 From: Vadim Chelyshov Date: Tue, 15 Jun 2021 20:38:02 +0300 Subject: [PATCH 2/3] [Bridge] Position - implement methods for accesing range --- .../src/dotty/tools/xsbt/PositionBridge.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java b/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java index 376ec6b361cb..075efd5b53e6 100644 --- a/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java +++ b/sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java @@ -125,4 +125,53 @@ public Optional pointerSpace() { public String toString() { return pos.toString(); } + + @Override + public Optional startOffset() { + if (src.content().length == 0) + return Optional.empty(); + else + return Optional.of(pos.start()); + } + + @Override + public Optional endOffset() { + if (src.content().length == 0) + return Optional.empty(); + else + return Optional.of(pos.end()); + } + + @Override + public Optional startLine() { + if (src.content().length == 0) + return Optional.empty(); + else + return Optional.of(pos.startLine() + 1); + } + + @Override + public Optional endLine() { + if (src.content().length == 0) + return Optional.empty(); + else + return Optional.of(pos.endLine() + 1); + } + + @Override + public Optional startColumn() { + if (src.content().length == 0) + return Optional.empty(); + else + return Optional.of(pos.startColumn()); + } + + @Override + public Optional endColumn() { + if (src.content().length == 0) + return Optional.empty(); + else + return Optional.of(pos.endColumn()); + } + } From 38156519ffb3288d39c57beb35a1d21c6e2f07b8 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 5 Jun 2021 13:00:43 +0200 Subject: [PATCH 3/3] Drop flaky test Fixes #12693 --- tests/neg/i12640.scala | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 tests/neg/i12640.scala diff --git a/tests/neg/i12640.scala b/tests/neg/i12640.scala deleted file mode 100644 index 7946525deeeb..000000000000 --- a/tests/neg/i12640.scala +++ /dev/null @@ -1,17 +0,0 @@ -package x - -trait CpsMonad[F[_]]: - def pure[A](x:A): F[A] - def flatMap[A,B](fa:F[A])(f: A=>F[B]): F[B] - -abstract sealed class CpsStream[-F[_],+T] - -case class Cons[F[_],T](head:T, tailFun: ()=>F[CpsStream[F,T]]) extends CpsStream[F,T] - -case class Empty[F[_]]() extends CpsStream[F,Nothing] - -def unfold[S,F[_]:CpsMonad,T](s0:S)(f:S => F[Option[(S,T)]]):F[CpsStream[F,T]] = - summon[CpsMonad[F]].flatMap(f(s0)){ - case Some(s1,a) => Cons(a, () => unfold(s1,f)) // error // error - case None => summon[CpsMonad[F]].pure(Empty[F]()) - } \ No newline at end of file