summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.sbt10
-rw-r--r--project/VersionUtil.scala2
-rw-r--r--scripts/common4
-rw-r--r--src/library/scala/collection/SeqLike.scala2
-rw-r--r--src/manual/scala/man1/scala.scala7
-rw-r--r--test/benchmarks/project/plugins.sbt2
-rw-r--r--test/junit/scala/collection/SeqLikeTest.scala19
7 files changed, 34 insertions, 12 deletions
diff --git a/build.sbt b/build.sbt
index 81323c9923..1ffce67465 100644
--- a/build.sbt
+++ b/build.sbt
@@ -463,7 +463,7 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target"
import collection.JavaConverters._
val inputs: Iterator[JarJar.Entry] = {
val repljlineClasses = (products in Compile in replJline).value.flatMap(base => Path.allSubpaths(base).map(x => (base, x._1)))
- val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data
+ val jlineJAR = findJar((dependencyClasspath in Compile).value, jlineDep).get.data
val jarFile = new JarFile(jlineJAR)
val jarEntries = jarFile.entries.asScala.filterNot(_.isDirectory).map(entry => JarJar.JarEntryInput(jarFile, entry))
def compiledClasses = repljlineClasses.iterator.map { case (base, file) => JarJar.FileInput(base, file) }
@@ -859,7 +859,7 @@ lazy val dist = (project in file("dist"))
val extraJars = (externalDependencyClasspath in Compile).value.map(a => (a.get(moduleID.key), a.data)).collect {
case (Some(m), f) if extraModules contains uniqueModule(m) => f
}
- val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data
+ val jlineJAR = findJar((dependencyClasspath in Compile).value, jlineDep).get.data
val mappings = extraJars.map(f => (f, targetDir / f.getName)) :+ ((jlineJAR, targetDir / "jline.jar"))
IO.copy(mappings, overwrite = true)
targetDir
@@ -1131,3 +1131,9 @@ intellijToSample := {
} else
s.log.info("Aborting.")
}
+
+/** Find a specific module's JAR in a classpath, comparing only organization and name */
+def findJar(files: Seq[Attributed[File]], dep: ModuleID): Option[Attributed[File]] = {
+ def extract(m: ModuleID) = (m.organization, m.name)
+ files.find(_.get(moduleID.key).map(extract _) == Some(extract(dep)))
+}
diff --git a/project/VersionUtil.scala b/project/VersionUtil.scala
index 1c2fff27b7..249aef8356 100644
--- a/project/VersionUtil.scala
+++ b/project/VersionUtil.scala
@@ -146,7 +146,7 @@ object VersionUtil {
def bootstrapDep(baseDir: File, path: String, libName: String): ModuleID = {
val sha = IO.read(baseDir / path / s"$libName.jar.desired.sha1").split(' ')(0)
bootstrapOrganization(path) % libName % sha from
- s"https://dl.bintray.com/typesafe/scala-sha-bootstrap/org/scala-lang/bootstrap/$sha/$path/$libName.jar"
+ s"https://repo.lightbend.com/typesafe/scala-sha-bootstrap/org/scala-lang/bootstrap/$sha/$path/$libName.jar"
}
/** Copy a boostrap dependency JAR that is on the classpath to a file */
diff --git a/scripts/common b/scripts/common
index 95389e5495..c4469348f4 100644
--- a/scripts/common
+++ b/scripts/common
@@ -168,8 +168,8 @@ function generateRepositoriesConfig() {
fi
cat >> "$sbtRepositoryConfig" << EOF
jcenter-cache: $jcenterCacheUrl
- typesafe-ivy-releases: https://dl.bintray.com/typesafe/ivy-releases/, [organisation]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
- sbt-plugin-releases: https://dl.bintray.com/sbt/sbt-plugin-releases/, [organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
+ typesafe-ivy-releases: https://repo.lightbend.com/typesafe/ivy-releases/, [organisation]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
+ sbt-plugin-releases: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/, [organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
maven-central
local
EOF
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index a26765027c..2d662257e5 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -113,7 +113,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
}
def indexWhere(p: A => Boolean, from: Int): Int = {
- var i = from
+ var i = from max 0
val it = iterator.drop(from)
while (it.hasNext) {
if (p(it.next())) return i
diff --git a/src/manual/scala/man1/scala.scala b/src/manual/scala/man1/scala.scala
index 9f97dd546c..3cfa9f8cb1 100644
--- a/src/manual/scala/man1/scala.scala
+++ b/src/manual/scala/man1/scala.scala
@@ -144,17 +144,14 @@ object scala extends Command {
Mono("-nocompdaemon") & " or " & Mono("-nc") & " option can be used to " &
"prevent this.",
- "If " & Mono("scala") & " is run from an sbaz(1) directory, " &
- "then it will add to its classpath any jars installed in the " &
- "lib directory of the sbaz directory. Additionally, if no " &
- "-classpath option is specified, then " & Mono("scala") &
+ "If no -classpath option is specified, then " & Mono("scala") &
" will add " & Quote(".") & ", the current directory, to the " &
"end of the classpath.")
val options = Section("OPTIONS",
"If any compiler options are specified, they must be first in the " &
- "command line and must be followed by a bare hypen (" & Quote("-") &
+ "command line and must be followed by a bare hyphen (" & Quote("-") &
") character. " &
"If no arguments are specified after the optional compiler arguments, " &
"then an interactive Scala shell is started. Otherwise, either a " &
diff --git a/test/benchmarks/project/plugins.sbt b/test/benchmarks/project/plugins.sbt
index e11aa29f3b..aa49ad9872 100644
--- a/test/benchmarks/project/plugins.sbt
+++ b/test/benchmarks/project/plugins.sbt
@@ -1,2 +1,2 @@
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
-addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.6")
+addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.16")
diff --git a/test/junit/scala/collection/SeqLikeTest.scala b/test/junit/scala/collection/SeqLikeTest.scala
new file mode 100644
index 0000000000..2ab682299d
--- /dev/null
+++ b/test/junit/scala/collection/SeqLikeTest.scala
@@ -0,0 +1,19 @@
+package scala.collection
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Assert._
+import org.junit.Test
+
+@RunWith(classOf[JUnit4])
+class SeqLikeTest {
+
+ @Test def `SI-9936 indexWhere`(): Unit = {
+ assertEquals(2, "abcde".indexOf('c', -1))
+ assertEquals(2, "abcde".indexOf('c', -2))
+ assertEquals(2, "abcde".toVector.indexOf('c', -1))
+ assertEquals(2, "abcde".toVector.indexOf('c', -2))
+ assertEquals(2, "abcde".toVector.indexWhere(_ == 'c', -1))
+ assertEquals(2, "abcde".toVector.indexWhere(_ == 'c', -2))
+ }
+}