Skip to content

Commit b8030f3

Browse files
committed
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)
1 parent 61cd1d8 commit b8030f3

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ trait MessageRendering {
9191
* @return aligned error message
9292
*/
9393
def errorMsg(pos: SourcePosition, msg: String, offset: Int)(implicit ctx: Context): String = {
94-
val padding = msg.lines.foldLeft(pos.startColumnPadding) { (pad, line) =>
94+
val padding = msg.linesIterator.foldLeft(pos.startColumnPadding) { (pad, line) =>
9595
val lineLength = stripColor(line).length
9696
val maxPad = math.max(0, ctx.settings.pageWidth.value - offset - lineLength) - offset
9797

9898
if (maxPad < pad.length) " " * maxPad
9999
else pad
100100
}
101101

102-
msg.lines
102+
msg.linesIterator
103103
.map { line => " " * (offset - 1) + "|" + padding + line}
104104
.mkString(sys.props("line.separator"))
105105
}

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
613613
else runMain(testSource.runClassPath) match {
614614
case Success(_) if !checkFile.isDefined || !checkFile.get.exists => // success!
615615
case Success(output) => {
616-
val outputLines = output.lines.toArray :+ DiffUtil.EOF
616+
val outputLines = output.linesIterator.toArray :+ DiffUtil.EOF
617617
val checkLines: Array[String] = Source.fromFile(checkFile.get).getLines().toArray :+ DiffUtil.EOF
618618
val sourceTitle = testSource.title
619619

@@ -1027,7 +1027,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10271027
case test.TimeoutFailure(title) =>
10281028
s" - test '$title' timed out"
10291029
case test.JavaCompilationFailure(msg) =>
1030-
s" - java compilation failed with:\n${ msg.lines.map(" " + _).mkString("\n") }"
1030+
s" - java compilation failed with:\n${ msg.linesIterator.map(" " + _).mkString("\n") }"
10311031
}.mkString("\n")
10321032
}
10331033

doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ trait CommentCleaner {
2121
SafeTags.replaceAllIn(javadoclessComment, { mtch =>
2222
Matcher.quoteReplacement(safeTagMarker + mtch.matched + safeTagMarker)
2323
})
24-
markedTagComment.lines.toList map (cleanLine)
24+
markedTagComment.linesIterator.toList map (cleanLine)
2525
}
2626
}

doc-tool/src/dotty/tools/dottydoc/staticsite/Page.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ trait Page {
115115
val withoutYaml = virtualFile(
116116
if (content.startsWith("---\n")) {
117117
val str =
118-
content.lines
118+
content.linesIterator
119119
.drop(1)
120120
.dropWhile(line => line != "---" && line != "...")
121121
.drop(1).mkString("\n")

tests/run/richs.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ object RichStringTest1 extends RichTest {
7575
object RichStringTest2 extends RichTest {
7676
def run: Unit = {
7777
println("\n" + getObjectName + ":")
78-
Console.print("s1: "); s1.lines foreach println
79-
Console.print("s2: "); s2.lines foreach println
80-
Console.print("s3: "); s3.lines foreach println
81-
Console.print("s4: "); s4.lines foreach println
82-
Console.print("s5: "); s5.lines foreach println
78+
Console.print("s1: "); s1.linesIterator foreach println
79+
Console.print("s2: "); s2.linesIterator foreach println
80+
Console.print("s3: "); s3.linesIterator foreach println
81+
Console.print("s4: "); s4.linesIterator foreach println
82+
Console.print("s5: "); s5.linesIterator foreach println
8383
}
8484
}
8585
object RichStringTest3 extends RichTest {

tests/run/t8015-ffc.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
object Test extends dotty.runtime.LegacyApp {
33
val ms = """This is a long multiline string
44
with \u000d\u000a CRLF embedded."""
5-
assert(ms.lines.size == 3, s"lines.size ${ms.lines.size}")
5+
assert(ms.linesIterator.size == 3, s"lines.size ${ms.linesIterator.size}")
66
assert(ms contains "\r\n CRLF", "no CRLF")
77
}

0 commit comments

Comments
 (0)