summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.sbt4
-rw-r--r--src/library/scala/collection/Iterator.scala23
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala2
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala2
-rw-r--r--test/junit/scala/collection/IteratorTest.scala6
5 files changed, 22 insertions, 15 deletions
diff --git a/build.sbt b/build.sbt
index 4ebe1e5686..fb382d146f 100644
--- a/build.sbt
+++ b/build.sbt
@@ -337,6 +337,8 @@ lazy val library = configureAsSubproject(project)
"-doc-root-content", (sourceDirectory in Compile).value + "/rootdoc.txt"
)
},
+ // macros in library+reflect are hard-wired to implementations with `FastTrack`.
+ incOptions := incOptions.value.withRecompileOnMacroDef(false),
includeFilter in unmanagedResources in Compile := "*.tmpl" | "*.xml" | "*.js" | "*.css" | "rootdoc.txt",
// Include *.txt files in source JAR:
mappings in Compile in packageSrc ++= {
@@ -364,6 +366,8 @@ lazy val reflect = configureAsSubproject(project)
.settings(
name := "scala-reflect",
description := "Scala Reflection Library",
+ // macros in library+reflect are hard-wired to implementations with `FastTrack`.
+ incOptions := incOptions.value.withRecompileOnMacroDef(false),
Osgi.bundleName := "Scala Reflect",
scalacOptions in Compile in doc ++= Seq(
"-skip-packages", "scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io"
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 1426278954..66d7493217 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -686,15 +686,15 @@ trait Iterator[+A] extends TraversableOnce[A] {
* handling of structural calls. It's not what's intended here.
*/
class Leading extends AbstractIterator[A] {
- var lookahead: mutable.Queue[A] = null
- var hd: A = _
+ private[this] var lookahead: mutable.Queue[A] = null
+ private[this] var hd: A = _
/* Status is kept with magic numbers
* 1 means next element is in hd and we're still reading into this iterator
* 0 means we're still reading but haven't found a next element
* -1 means we are done reading into the iterator, so we must rely on lookahead
* -2 means we are done but have saved hd for the other iterator to use as its first element
*/
- var status = 0
+ private[this] var status = 0
private def store(a: A) {
if (lookahead == null) lookahead = new mutable.Queue[A]
lookahead += a
@@ -718,26 +718,23 @@ trait Iterator[+A] extends TraversableOnce[A] {
}
else empty.next()
}
- def finish(): Boolean = {
- if (status == -1) false
- else if (status == -2) {
+ def finish(): Boolean = status match {
+ case -2 => status = -1 ; true
+ case -1 => false
+ case 1 => store(hd) ; status = 0 ; finish()
+ case 0 =>
status = -1
- true
- }
- else {
- if (status == 1) store(hd)
while (self.hasNext) {
val a = self.next()
if (p(a)) store(a)
else {
hd = a
- status = -1
return true
}
}
false
- }
}
+ def trailer: A = hd
}
val leading = new Leading
@@ -770,7 +767,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
if (status > 0) self.next()
else {
status = 1
- val ans = myLeading.hd
+ val ans = myLeading.trailer
myLeading = null
ans
}
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index 626540425f..7fcc8c9f2d 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -384,7 +384,7 @@ private[concurrent] object Promise {
private[this] final def thisAs[S]: Future[S] = future.asInstanceOf[Future[S]]
override def onSuccess[U](pf: PartialFunction[T, U])(implicit executor: ExecutionContext): Unit = ()
- override def failed: Future[Throwable] = thisAs[Throwable]
+ override def failed: Future[Throwable] = KeptPromise(Success(result.exception)).future
override def foreach[U](f: T => U)(implicit executor: ExecutionContext): Unit = ()
override def map[S](f: T => S)(implicit executor: ExecutionContext): Future[S] = thisAs[S]
override def flatMap[S](f: T => Future[S])(implicit executor: ExecutionContext): Future[S] = thisAs[S]
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala
index d0de2f5542..a1934efdd0 100644
--- a/test/files/jvm/future-spec/FutureTests.scala
+++ b/test/files/jvm/future-spec/FutureTests.scala
@@ -123,7 +123,7 @@ class FutureTests extends MinimalScalaTest {
assert(f.mapTo[String] eq f, "Future.mapTo must be the same instance as Future.mapTo")
assert(f.zip(f) eq f, "Future.zip must be the same instance as Future.zip")
assert(f.flatten eq f, "Future.flatten must be the same instance as Future.flatten")
- assert(f.failed eq f, "Future.failed must be the same instance as Future.failed")
+ assert(f.failed.value == Some(Success(e)), "Future.failed.failed must become successful") // SI-10034
ECNotUsed(ec => f.foreach(_ => fail("foreach should not have been called"))(ec))
ECNotUsed(ec => f.onSuccess({ case _ => fail("onSuccess should not have been called") })(ec))
diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala
index 09061a3b29..1709e3c1bf 100644
--- a/test/junit/scala/collection/IteratorTest.scala
+++ b/test/junit/scala/collection/IteratorTest.scala
@@ -186,6 +186,12 @@ class IteratorTest {
assertEquals(1, y.next)
assertFalse(x.hasNext) // was true, after advancing underlying iterator
}
+ // SI-9913
+ @Test def `span leading iterator finishes at state -1`(): Unit = {
+ val (yes, no) = Iterator(1, 2, 3).span(_ => true)
+ assertFalse(no.hasNext)
+ assertTrue(yes.hasNext)
+ }
// SI-9623
@Test def noExcessiveHasNextInJoinIterator: Unit = {
var counter = 0