Skip to content

Commit

Permalink
Fix compilation with JDK 11
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
smarter committed Oct 1, 2018
1 parent ac89c86 commit befe1ce
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ 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

if (maxPad < pad.length) " " * maxPad
else pad
}

msg.lines
msg.linesIterator
.map { line => " " * (offset - 1) + "|" + padding + line}
.mkString(sys.props("line.separator"))
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion doc-tool/src/dotty/tools/dottydoc/staticsite/Page.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions tests/run/richs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/run/t8015-ffc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit befe1ce

Please sign in to comment.