summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala8
-rw-r--r--src/library/scala/collection/Iterator.scala2
-rw-r--r--src/library/scala/concurrent/impl/ExecutionContextImpl.scala8
-rw-r--r--test/files/jvm/t7146.check5
-rw-r--r--test/files/jvm/t7146.scala23
-rw-r--r--test/files/run/t6827.scala3
6 files changed, 42 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 341dbfbe1f..7a3ab00578 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -908,6 +908,7 @@ trait Namers extends MethodSynthesis {
// to use. clazz is the ModuleClass. sourceModule works also for classes defined in methods.
val module = clazz.sourceModule
for (cda <- module.attachments.get[ConstructorDefaultsAttachment]) {
+ debuglog(s"Storing the template namer in the ConstructorDefaultsAttachment of ${module.debugLocationString}.")
cda.companionModuleClassNamer = templateNamer
}
val classTp = ClassInfoType(parents, decls, clazz)
@@ -1229,8 +1230,11 @@ trait Namers extends MethodSynthesis {
// module's templateNamer to classAndNamerOfModule
module.attachments.get[ConstructorDefaultsAttachment] match {
// by martin: the null case can happen in IDE; this is really an ugly hack on top of an ugly hack but it seems to work
- // later by lukas: disabled when fixing SI-5975, i think it cannot happen anymore
- case Some(cda) /*if cma.companionModuleClassNamer == null*/ =>
+ case Some(cda) =>
+ if (cda.companionModuleClassNamer == null) {
+ debugwarn(s"SI-6576 The companion module namer for $meth was unexpectedly null")
+ return
+ }
val p = (cda.classWithDefault, cda.companionModuleClassNamer)
moduleNamer = Some(p)
p
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 696bc4ab5c..2bb5bd1df9 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -1111,7 +1111,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
* $willNotTerminateInf
*/
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = {
- require(start >= 0 && start < xs.length, s"start $start out of range ${xs.length}")
+ require(start >= 0 && (start < xs.length || xs.length == 0), s"start $start out of range ${xs.length}")
var i = start
val end = start + math.min(len, xs.length - start)
while (i < end && hasNext) {
diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
index 43b437dbc6..0aa6b37ffc 100644
--- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
+++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -19,16 +19,16 @@ import scala.util.control.NonFatal
private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter: Throwable => Unit) extends ExecutionContextExecutor {
+ // Placed here since the creation of the executor needs to read this val
+ private[this] val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler {
+ def uncaughtException(thread: Thread, cause: Throwable): Unit = reporter(cause)
+ }
val executor: Executor = es match {
case null => createExecutorService
case some => some
}
- private[this] val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler {
- def uncaughtException(thread: Thread, cause: Throwable): Unit = reporter(cause)
- }
-
// Implement BlockContext on FJP threads
class DefaultThreadFactory(daemonic: Boolean) extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory {
def wire[T <: Thread](thread: T): T = {
diff --git a/test/files/jvm/t7146.check b/test/files/jvm/t7146.check
new file mode 100644
index 0000000000..7c76040205
--- /dev/null
+++ b/test/files/jvm/t7146.check
@@ -0,0 +1,5 @@
+should be scala.concurrent.impl.ExecutionContextImpl == true
+should be scala.concurrent.forkjoin.ForkJoinPool == true
+should have non-null UncaughtExceptionHandler == true
+should be a scala.concurrent.impl.ExecutionContextImpl UncaughtExceptionHandler == true
+should just print out on uncaught == true
diff --git a/test/files/jvm/t7146.scala b/test/files/jvm/t7146.scala
new file mode 100644
index 0000000000..2bd03d6d02
--- /dev/null
+++ b/test/files/jvm/t7146.scala
@@ -0,0 +1,23 @@
+import java.util.concurrent.Executor
+import scala.concurrent._
+import scala.util.control.NoStackTrace
+
+object Test {
+ def main(args: Array[String]) {
+ println("should be scala.concurrent.impl.ExecutionContextImpl == " +
+ ExecutionContext.global.toString.startsWith("scala.concurrent.impl.ExecutionContextImpl"))
+ val i = ExecutionContext.global.asInstanceOf[{ def executor: Executor }]
+ println("should be scala.concurrent.forkjoin.ForkJoinPool == " +
+ i.executor.toString.startsWith("scala.concurrent.forkjoin.ForkJoinPool"))
+ val u = i.executor.
+ asInstanceOf[{ def getUncaughtExceptionHandler: Thread.UncaughtExceptionHandler }].
+ getUncaughtExceptionHandler
+ println("should have non-null UncaughtExceptionHandler == " + (u ne null))
+ println("should be a scala.concurrent.impl.ExecutionContextImpl UncaughtExceptionHandler == " +
+ u.toString.startsWith("scala.concurrent.impl.ExecutionContextImpl"))
+ print("should just print out on uncaught == ")
+ u.uncaughtException(Thread.currentThread, new Throwable {
+ override def printStackTrace() { println("true") }
+ })
+ }
+}
diff --git a/test/files/run/t6827.scala b/test/files/run/t6827.scala
index 7e8918e3dc..8e17af09e2 100644
--- a/test/files/run/t6827.scala
+++ b/test/files/run/t6827.scala
@@ -28,4 +28,7 @@ object Test extends App {
tryit("read -1", 0, -1)
tryit("invalid read 0", 30, 0)
tryit("invalid read -1", 30, -1)
+
+ // okay, see SI-7128
+ "...".toIterator.copyToArray(new Array[Char](0), 0, 0)
}