8000 Add AdoptOpenJDK JDK 11 to the PR validation by eed3si9n · Pull Request #8207 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Add AdoptOpenJDK JDK 11 to the PR validation #8207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[nomerge] Restore/use linesIterator to avoid conflict String.lines
Which was added in JDK 11.
  • Loading branch information
retronym authored and lrytz committed Jul 12, 2019
commit 3849c0abc97f0aa0faa8ee847bb4b1e57bb30511
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ trait Contexts { self: Analyzer =>

def enclosingContextChain: List[Context] = this :: outer.enclosingContextChain

private def treeTruncated = tree.toString.replaceAll("\\s+", " ").lines.mkString("\\n").take(70)
private def treeTruncated = tree.toString.replaceAll("\\s+", " ").linesIterator.mkString("\\n").take(70)
private def treeIdString = if (settings.uniqid.value) "#" + System.identityHashCode(tree).toString.takeRight(3) else ""
private def treeString = tree match {
case x: Import => "" + x
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4797,7 +4797,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (e.errPos samePointAs tree.pos) {
val header = f"${e.errMsg}%n Expression does not convert to assignment because:%n "
val expansion = f"%n expansion: ${show(convo)}"
NormalTypeError(tree, err.errors.flatMap(_.errMsg.lines.toList).mkString(header, f"%n ", expansion))
NormalTypeError(tree, err.errors.flatMap(_.errMsg.linesIterator.toList).mkString(header, f"%n ", expansion))
} else e
}
def advice2(errors: List[AbsTypeError]): List[AbsTypeError] =
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/util/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object PathResolver {
}
implicit class AsLines(val s: String) extends AnyVal {
// sm"""...""" could do this in one pass
def asLines = s.trim.stripMargin.lines.mkLines
def asLines = s.trim.stripMargin.linesIterator.mkLines
}

/** pretty print class path */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ abstract class InteractiveTest
loadSources()
runDefaultTests()
}
}.lines.map(normalize).foreach(println)
}.linesIterator.map(normalize).foreach(println)
}

protected def normalize(s: String) = s
Expand Down
2364
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ trait InteractiveTestSettings extends TestSettings with PresentationCompilerInst
val str = try File(optsFile).slurp() catch {
case e: java.io.IOException => ""
}
str.lines.filter(!_.startsWith(CommentStartDelimiter)).mkString(" ")
str.linesIterator.filter(!_.startsWith(CommentStartDelimiter)).mkString(" ")
}

override protected def printClassPath(implicit reporter: Reporter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ abstract class IcodeComparison extends DirectTest {
// here depends on it (collectIcode will be called multiple times, and we can't allow crosstalk
// between calls). So we are careful to use `slurp` which does call `close`, and careful to
// check that `delete` returns true indicating successful deletion.
try icodeFiles sortBy (_.name) flatMap (f => f.slurp().lines.toList)
try icodeFiles sortBy (_.name) flatMap (f => f.slurp().linesIterator.toList)
finally icodeFiles foreach (f => require(f.delete()))
}

Expand Down
6 changes: 3 additions & 3 deletions src/partest-extras/scala/tools/partest/ReplTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class ReplTest extends DirectTest {
log("eval(): settings = " + s)
val transcript = ILoop.runForTranscript(code, s, inSession = inSession)
log(s"transcript[[$transcript]]")
val lines = transcript.lines
val lines = transcript.linesIterator
val clean =
if (welcoming) {
val welcome = "(Welcome to Scala).*".r
Expand All @@ -55,7 +55,7 @@ abstract class ReplTest extends DirectTest {
case s => s
}
} else {
lines.drop(header.lines.size)
lines.drop(header.linesIterator.size)
}
clean.map(normalize)
}
Expand All @@ -75,7 +75,7 @@ abstract class SessionTest extends ReplTest {
def session: String = testPath.changeExtension("check").toFile.slurp

/** Expected output, as an iterator, optionally marginally stripped. */
def expected = if (stripMargins) session.stripMargin.lines else session.lines
def expected = if (stripMargins) session.stripMargin.linesIterator else session.linesIterator

/** Override with true if session is a """string""" with margin indent. */
def stripMargins: Boolean = false
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/Printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ trait Printers extends api.Printers { self: SymbolTable =>

case Literal(k @ Constant(s: String)) if s.contains(Chars.LF) =>
val tq = "\"" * 3
val lines = s.lines.toList
val lines = s.linesIterator.toList
if (lines.lengthCompare(1) <= 0) print(k.escapedStringValue)
else {
val tqp = """["]{3}""".r
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/util/StringOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ trait StringOps {
else s.substring(0, end)
}
/** Breaks the string into lines and strips each line before reassembling. */
def trimAllTrailingSpace(s: String): String = s.lines.map(trimTrailingSpace).mkString(EOL)
def trimAllTrailingSpace(s: String): String = s.linesIterator.map(trimTrailingSpace).mkString(EOL)

def decompose(str: String, sep: Char): List[String] = {
def ws(start: Int): List[String] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ trait JLineHistory extends JHistory with History {
def moveToEnd(): Unit

override def historicize(text: String): Boolean = {
text.lines foreach add
text.linesIterator foreach add
moveToEnd()
true
}
Expand Down
4 changes: 2 additions & 2 deletions src/repl/scala/tools/nsc/interpreter/ILoop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) extend
tmp.safeSlurp() match {
case Some(edited) if edited.trim.isEmpty => echo("Edited text is empty.")
case Some(edited) =>
echo(edited.lines map ("+" + _) mkString "\n")
echo(edited.linesIterator map ("+" + _) mkString "\n")
val res = intp interpret edited
if (res == IR.Incomplete) diagnose(edited)
else {
Expand Down Expand Up @@ -812,7 +812,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) extend
val input = readWhile(s => delimiter.isEmpty || delimiter.get != s) mkString "\n"
val text = (
margin filter (_.nonEmpty) map {
case "-" => input.lines map (_.trim) mkString "\n"
case "-" => input.linesIterator map (_.trim) mkString "\n"
case m => input stripMargin m.head // ignore excess chars in "<<||"
} getOrElse input
).trim
Expand Down
4 changes: 2 additions & 2 deletions src/repl/scala/tools/nsc/interpreter/IMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
if (printResults && result != "")
printMessage(result stripSuffix "\n")
else if (isReplDebug) // show quiet-mode activity
printMessage(result.trim.lines map ("[quiet] " + _) mkString "\n")
printMessage(result.trim.linesIterator map ("[quiet] " + _) mkString "\n")

// Book-keeping. Have to record synthetic requests too,
// as they may have been issued for information, e.g. :type
Expand Down Expand Up @@ -1238,7 +1238,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
/** Secret bookcase entrance for repl debuggers: end the line
* with "// show" and see what's going on.
*/
def isShow = code.lines exists (_.trim endsWith "// show")
def isShow = code.linesIterator exists (_.trim endsWith "// show")
if (isReplDebug || isShow) {
beSilentDuring(parse(code)) match {
case parse.Success(ts) =>
Expand Down
2 changes: 1 addition & 1 deletion src/repl/scala/tools/nsc/interpreter/Pasted.scala
< B41A /table>
4 changes: 2 additions & 2 deletions src/repl/scala/tools/nsc/interpreter/Power.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class Pasted(prompt: String) {
def interpret(line: String): IR.Result
def echo(message: String): Unit

val PromptString = prompt.lines.toList.last
val PromptString = prompt.linesIterator.toList.last
val AltPromptString = "scala> "
val ContinuePrompt = replProps.continuePrompt
val ContinueString = replProps.continueText // " | "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re
|definitions.{ getClass => _, _ }
|power.rutil._
|replImplicits._
|treedsl.CODE._""".stripMargin.lines
|treedsl.CODE._""".stripMargin.linesIterator

def init = customInit getOrElse initImports.mkString("import ", ", ", "")

Expand All @@ -158,7 +158,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re
// Then we import everything from $r.
intp interpret s"import ${ intp.originalPath("$r") }._"
// And whatever else there is to do.
init.lines foreach (intp interpret _)
init.linesIterator foreach (intp interpret _)
}

trait LowPriorityInternalInfo {
Expand Down
2 changes: 1 addition & 1 deletion src/repl/scala/tools/nsc/interpreter/ReplProps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ReplProps {
val continueString = F438 Prop[String]("scala.repl.continue").option getOrElse "| "
val continueText = {
val text = enversion(continueString)
val margin = promptText.lines.toList.last.length - text.length
val margin = promptText.linesIterator.toList.last.length - text.length
if (margin > 0) " " * margin + text else text
}
val continuePrompt = encolor(continueText)
Expand Down
2 changes: 1 addition & 1 deletion src/repl/scala/tools/nsc/interpreter/ReplReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ReplReporter(intp: IMain) extends ConsoleReporter(intp.settings, Console.i
case INFO => RESET
}

private val promptLength = replProps.promptText.lines.toList.last.length
private val promptLength = replProps.promptText.linesIterator.toList.last.length
private val indentation = " " * promptLength

// colorized console labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
SafeTags.replaceAllIn(javadoclessComment, { mtch =>
java.util.regex.Matcher.quoteReplacement(safeTagMarker + mtch.matched + safeTagMarker)
})
markedTagComment.lines.toList map (cleanLine(_))
markedTagComment.linesIterator.toList map (cleanLine(_))
}

/** Parses a comment (in the form of a list of lines) to a `Comment`
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/global-showdef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Bippy {

def interesting(line: String) = (line contains "def showdefTestMember") || (line startsWith "<<-- ")

def run(args: String*) = slurp(args: _*).lines filter interesting foreach println
def run(args: String*) = slurp(args: _*).linesIterator filter interesting foreach println

classes.zipAll(objects, "", "") foreach {
case (c, "") => run("-Xshow-class", c)
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/repl-paste-parse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Test extends DirectTest {
val w = new StringWriter
val p = new PrintWriter(w, true)
new ILoop(r, p).process(settings)
w.toString.lines foreach { s =>
w.toString.linesIterator foreach { s =>
if (!s.startsWith("Welcome to Scala")) println(s)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/repl-serialization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Test {
imain = IMain(settings)
println("== evaluating lines")
imain.directBind("extract", "(AnyRef => Unit)", extract)
code.lines.foreach(imain.interpret)
code.linesIterator.foreach(imain.interpret)

val virtualFile: AbstractFile = extract.value.getClass.getClassLoader.asInstanceOf[AbstractFileClassLoader].root
val newLoader = new AbstractFileClassLoader(virtualFile, getClass.getClassLoader)
Expand Down
10 changes: 5 additions & 5 deletions test/files/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 {
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 test/files/run/t10471.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Test extends StoreReporterDirectTest {
Console.withOut(baos)(Console.withErr(baos)(compile()))
val out = baos.toString("UTF-8")

val fooDefs = out.lines.filter(_.contains("private[this] val foo")).map(_.trim).toList
val fooDefs = out.linesIterator.filter(_.contains("private[this] val foo")).map(_.trim).toList
assert(fooDefs.length == 2)
assert(fooDefs.forall(_.startsWith("@blort private[this] val foo: String =")), fooDefs)
}
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t5256h.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ object Test extends App {
println(c)
println(c.fullName)
// under -Xcheckinit there's an additional $init$ field
c.info.toString.lines.filter(_ != " private var bitmap$init$0: Boolean") foreach println
c.info.toString.linesIterator.filter(_ != " private var bitmap$init$0: Boolean") foreach println
}
2 changes: 1 addition & 1 deletion test/files/run/t6130.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object Test extends StoreReporterDirectTest {
Console.withOut(baos)(Console.withErr(baos)(compile()))
val out = baos.toString("UTF-8")

val unapplySelectorDummies = out.lines.filter(_.contains("<unapply-selector>")).map(_.trim).toList
val unapplySelectorDummies = out.linesIterator.filter(_.contains("<unapply-selector>")).map(_.trim).toList
assert(unapplySelectorDummies.isEmpty, unapplySelectorDummies)
}
}
2 changes: 1 addition & 1 deletion test/files/run/t6240-universe-code-gen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object Test extends App {
val actualFile = new java.io.File(testFile.getParent + "/../../../src/reflect/scala/reflect/runtime/JavaUniverseForce.scala").getCanonicalFile
val actual = scala.io.Source.fromFile(actualFile)
val actualLines = actual.getLines.toList
val generatedLines = code.lines.toList
val generatedLines = code.linesIterator.toList
if (actualLines != generatedLines) {
val msg = s"""|${actualFile} must be updated.
|===========================================================
Expand Down
14 changes: 7 additions & 7 deletions test/files/run/t6502.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import scala.tools.partest._
object Test extends StoreReporterDirectTest {
def code = ???

lazy val headerLength = replProps.welcome.lines.size
lazy val promptLength = replProps.prompt.lines.size - 1 // extra newlines
lazy val headerLength = replProps.welcome.linesIterator.size
lazy val promptLength = replProps.prompt.linesIterator.size - 1 // extra newlines

def compileCode(code: String, jarFileName: String) = {
val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
Expand Down Expand Up @@ -55,12 +55,12 @@ object Test extends StoreReporterDirectTest {
|test.Test.test()
|""".stripMargin.trim
val output = ILoop.run(codeToRun, settings)
var lines = output.lines.drop(headerLength)
var lines = output.linesIterator.drop(headerLength)
lines = lines drop promptLength
val added = lines.next
assert (
added.contains("Added") && added.contains("test1.jar"),
s"[${added}] in [${output.lines.mkString("/")}]"
s"[${added}] in [${output.linesIterator.mkString("/")}]"
)
lines = lines drop promptLength
val r = lines.next
Expand All @@ -78,7 +78,7 @@ object Test extends StoreReporterDirectTest {
|:require ${testOutput.path}/$jar2
|""".stripMargin.trim
val output = ILoop.run(codeToRun, settings)
var lines = output.lines.drop(headerLength)
var lines = output.linesIterator.drop(headerLength)
lines = lines drop promptLength
val added = lines.next
assert(added.contains("Added") && added.contains("test1.jar"), added)
Expand All @@ -99,7 +99,7 @@ object Test extends StoreReporterDirectTest {
|test.Test3.test()
|""".stripMargin.trim
val output = ILoop.run(codeToRun, settings)
var lines = output.lines.drop(headerLength)
var lines = output.linesIterator.drop(headerLength)
lines = lines drop promptLength
val added = lines.next
assert(added.contains("Added") && added.contains("test1.jar"), added)
Expand All @@ -116,7 +116,7 @@ object Test extends StoreReporterDirectTest {
|:require ${testOutput.path}/$jar1
|""".stripMargin.trim
val output = ILoop.run(codeToRun, settings)
var lines = output.lines.drop(headerLength)
var lines = output.linesIterator.drop(headerLength)
lines = lines drop promptLength
val added = lines.next
assert(added.contains("Added") && added.contains("test1.jar"), added)
Expand Down
10 changes: 7 additions & 3 deletions test/files/run/t6669.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ object Test extends App {
scala.tools.scalap.Main.main(Array("-verbose", "java.lang.Object"))
}

val currentLocationCpFragment = File.pathSeparator + "."
// on java 10, lone . instead of something/.
//val currentLocationCpFragment = File.pathSeparator + "."

// let's assume dirs don't normally have dots
def hasCurrentDir(s: String): Boolean = s.linesIterator.next.split("[ ,:;]").exists(_.endsWith("."))

// now make sure we saw the '.' in the classpath
val msg1 = baos.toString()
assert(msg1 contains currentLocationCpFragment, s"Did not see '.' in the default class path. Full results were:\n$msg1")
assert(hasCurrentDir(msg1), s"Did not see '.' in the default class path. Full results were:\n$msg1")

// then test again with a user specified classpath
baos.reset
Expand All @@ -25,5 +29,5 @@ object Test extends App {

// now make sure we did not see the '.' in the classpath
val msg2 = baos.toString()
assert(!(msg2 contains currentLocationCpFragment), s"Did saw '.' in the user specified class path. Full results were:\n$msg2")
assert(!hasCurrentDir(msg2), s"Did see '.' in the user specified class path. Full results were:\n$msg2")
}
2 changes: 1 addition & 1 deletion
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
object Test extends App {
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")
}
4 changes: 2 additions & 2 deletions test/files/run/t8549.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object Test extends App {
def patch(file: File, line: Int, prevResult: String, result: String) {
amend(file) {
content =>
content.lines.toList.zipWithIndex.map {
content.linesIterator.toList.zipWithIndex.map {
case (content, i) if i == line - 1 =>
val newContent = content.replaceAllLiterally(quote(prevResult), quote(result))
if (newContent != content)
Expand All @@ -48,7 +48,7 @@ object Test extends App {
val newComment = s" // Generated on $timestamp with Scala ${scala.util.Properties.versionString})"
amend(file) {
content =>
content.lines.toList.map {
content.linesIterator.toList.map {
f => f.replaceAll("""^ +// Generated on.*""", newComment)
}.mkString("\n")
}
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t9097.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ object Test extends StoreReporterDirectTest {
assert(!storeReporter.hasErrors, message = filteredInfos map (_.msg) mkString "; ")
val out = baos.toString("UTF-8")
// was 2 before the fix, the two PackageDefs for a would both contain the ClassDef for the closure
assert(out.lines.count(_ contains "def $anonfun$hihi$1(x$1: Int): String") == 1, out)
assert(out.linesIterator.count(_ contains "def $anonfun$hihi$1(x$1: Int): String") == 1, out)
}
}
2 changes: 1 addition & 1 deletion test/junit/scala/io/SourceTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SourceTest {
private def in = new ByteArrayInputStream(sampler.getBytes)

@Test def canIterateLines() = {
assertEquals(sampler.lines.size, (Source fromString sampler).getLines.size)
assertEquals(sampler.linesIterator.size, (Source fromString sampler).getLines.size)
}
@Test def loadFromResource() = {
val res = Source.fromResource("rootdoc.txt")
Expand Down
Loading
0