From befe1ce429c65cd6cad5e497e0907d8cd598d135 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 18 Sep 2018 17:47:21 +0200 Subject: [PATCH] Fix compilation with JDK 11 The extension method lines is now shadowed by String#lines that returns a Stream, use linesIterator instead (it used to be deprecated in favor of lines, but has been undeprecated in 2.12.7) --- .../dotty/tools/dotc/reporting/MessageRendering.scala | 4 ++-- compiler/test/dotty/tools/vulpix/ParallelTesting.scala | 4 ++-- .../tools/dottydoc/model/comment/CommentCleaner.scala | 2 +- .../src/dotty/tools/dottydoc/staticsite/Page.scala | 2 +- tests/run/richs.scala | 10 +++++----- tests/run/t8015-ffc.scala | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala b/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala index 45f1601bdc98..0cdf717c6f2f 100644 --- a/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala +++ b/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala @@ -91,7 +91,7 @@ trait MessageRendering { * @return aligned error message */ def errorMsg(pos: SourcePosition, msg: String, offset: Int)(implicit ctx: Context): String = { - val padding = msg.lines.foldLeft(pos.startColumnPadding) { (pad, line) => + val padding = msg.linesIterator.foldLeft(pos.startColumnPadding) { (pad, line) => val lineLength = stripColor(line).length val maxPad = math.max(0, ctx.settings.pageWidth.value - offset - lineLength) - offset @@ -99,7 +99,7 @@ trait MessageRendering { else pad } - msg.lines + msg.linesIterator .map { line => " " * (offset - 1) + "|" + padding + line} .mkString(sys.props("line.separator")) } diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index 0b2325ee549a..a49f77aa0501 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -613,7 +613,7 @@ trait ParallelTesting extends RunnerOrchestration { self => else runMain(testSource.runClassPath) match { case Success(_) if !checkFile.isDefined || !checkFile.get.exists => // success! case Success(output) => { - val outputLines = output.lines.toArray :+ DiffUtil.EOF + val outputLines = output.linesIterator.toArray :+ DiffUtil.EOF val checkLines: Array[String] = Source.fromFile(checkFile.get).getLines().toArray :+ DiffUtil.EOF val sourceTitle = testSource.title @@ -1027,7 +1027,7 @@ trait ParallelTesting extends RunnerOrchestration { self => case test.TimeoutFailure(title) => s" - test '$title' timed out" case test.JavaCompilationFailure(msg) => - s" - java compilation failed with:\n${ msg.lines.map(" " + _).mkString("\n") }" + s" - java compilation failed with:\n${ msg.linesIterator.map(" " + _).mkString("\n") }" }.mkString("\n") } diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala index 5b60cd5f9c69..cfcf788af9dd 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala @@ -21,6 +21,6 @@ trait CommentCleaner { SafeTags.replaceAllIn(javadoclessComment, { mtch => Matcher.quoteReplacement(safeTagMarker + mtch.matched + safeTagMarker) }) - markedTagComment.lines.toList map (cleanLine) + markedTagComment.linesIterator.toList map (cleanLine) } } diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/Page.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/Page.scala index 1ec870dc236e..7de72693aaea 100644 --- a/doc-tool/src/dotty/tools/dottydoc/staticsite/Page.scala +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/Page.scala @@ -115,7 +115,7 @@ trait Page { val withoutYaml = virtualFile( if (content.startsWith("---\n")) { val str = - content.lines + content.linesIterator .drop(1) .dropWhile(line => line != "---" && line != "...") .drop(1).mkString("\n") diff --git a/tests/run/richs.scala b/tests/run/richs.scala index ea870b9c4565..59f833245509 100644 --- a/tests/run/richs.scala +++ b/tests/run/richs.scala @@ -75,11 +75,11 @@ object RichStringTest1 extends RichTest { object RichStringTest2 extends RichTest { def run: Unit = { println("\n" + getObjectName + ":") - Console.print("s1: "); s1.lines foreach println - Console.print("s2: "); s2.lines foreach println - Console.print("s3: "); s3.lines foreach println - Console.print("s4: "); s4.lines foreach println - Console.print("s5: "); s5.lines foreach println + Console.print("s1: "); s1.linesIterator foreach println + Console.print("s2: "); s2.linesIterator foreach println + Console.print("s3: "); s3.linesIterator foreach println + Console.print("s4: "); s4.linesIterator foreach println + Console.print("s5: "); s5.linesIterator foreach println } } object RichStringTest3 extends RichTest { diff --git a/tests/run/t8015-ffc.scala b/tests/run/t8015-ffc.scala index f458cc2acb46..6a4b53dee77e 100644 --- a/tests/run/t8015-ffc.scala +++ b/tests/run/t8015-ffc.scala @@ -2,6 +2,6 @@ object Test extends dotty.runtime.LegacyApp { val ms = """This is a long multiline string with \u000d\u000a CRLF embedded.""" - assert(ms.lines.size == 3, s"lines.size ${ms.lines.size}") + assert(ms.linesIterator.size == 3, s"lines.size ${ms.linesIterator.size}") assert(ms contains "\r\n CRLF", "no CRLF") }