From 8c3d3cb6422f490be68741378169ea5f3084a277 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 3 Apr 2017 12:37:48 -0700 Subject: Revert "Handle WrappedArray the same way as ArrayOps for binary compatibility" This reverts commit f24c2603d0acee5bcb6d5d80bf1e1a4645fa74f0. --- bincompat-forward.whitelist.conf | 56 +++++----------------- .../scala/collection/mutable/WrappedArray.scala | 44 ++++++++--------- 2 files changed, 33 insertions(+), 67 deletions(-) diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index a5b3d75a8e..1db1e2f408 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -769,6 +769,18 @@ filter { matchName="scala.collection.mutable.WrappedArray#ofShort.emptyImpl" problemName=DirectMissingMethodProblem }, + { + matchName="scala.collection.mutable.WrappedArray.sliceImpl" + problemName=DirectMissingMethodProblem + }, + { + matchName="scala.collection.mutable.WrappedArray.emptyImpl" + problemName=DirectMissingMethodProblem + }, + { + matchName="scala.collection.mutable.WrappedArray.slice" + problemName=IncompatibleResultTypeProblem + }, { matchName="scala.collection.mutable.WrappedArray#ofRef.sliceImpl" problemName=DirectMissingMethodProblem @@ -881,50 +893,6 @@ filter { matchName="scala.collection.mutable.ArrayOps#ofBoolean.emptyImpl$extension" problemName=DirectMissingMethodProblem }, - { - matchName="scala.collection.mutable.WrappedArray$ofByte" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofBoolean" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofChar" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofDouble" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofShort" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofRef" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofUnit" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofInt" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArrayImpl" - problemName=MissingClassProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofLong" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.WrappedArray$ofFloat" - problemName=MissingTypesProblem - }, { matchName="scala.collection.mutable.WrappedArray#ofFloat.sliceImpl" problemName=DirectMissingMethodProblem diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala index eba740bfe4..81e0e64fb2 100644 --- a/src/library/scala/collection/mutable/WrappedArray.scala +++ b/src/library/scala/collection/mutable/WrappedArray.scala @@ -72,6 +72,17 @@ extends AbstractSeq[T] else super.toArray[U] } + override def slice(from: Int, until: Int): WrappedArray[T] = { + val start = if (from < 0) 0 else from + if (until <= start || start >= repr.length) + return emptyImpl + val end = if (until > length) length else until + sliceImpl(start, end) + } + //retain existing functionallity for existing implementations outside this file + protected def emptyImpl: WrappedArray[T] = newBuilder.result() + //retain existing functionallity for existing implementations outside this file + protected def sliceImpl(from: Int, until: Int): WrappedArray[T] = super.slice(from, until) override def stringPrefix = "WrappedArray" @@ -82,20 +93,7 @@ extends AbstractSeq[T] */ override protected[this] def newBuilder: Builder[T, WrappedArray[T]] = new WrappedArrayBuilder[T](elemTag) -} - -private[mutable] abstract class WrappedArrayImpl[T] extends WrappedArray[T] { - override def slice(from: Int, until: Int): WrappedArray[T] = { - val start = if (from < 0) 0 else from - if (until <= start || start >= repr.length) - return emptyImpl - val end = if (until > length) length else until - sliceImpl(start, end) - } - - protected def emptyImpl: WrappedArray[T] - protected def sliceImpl(from: Int, until: Int): WrappedArray[T] } /** A companion object used to create instances of `WrappedArray`. @@ -145,7 +143,7 @@ object WrappedArray { private val emptyWrappedChar = new ofChar(new Array[Char](0)) private val emptyWrappedBoolean = new ofBoolean(new Array[Boolean](0)) - final class ofRef[T <: AnyRef](val array: Array[T]) extends WrappedArrayImpl[T] with Serializable { + final class ofRef[T <: AnyRef](val array: Array[T]) extends WrappedArray[T] with Serializable { lazy val elemTag = ClassTag[T](arrayElementClass(array.getClass)) def length: Int = array.length def apply(index: Int): T = array(index).asInstanceOf[T] @@ -154,7 +152,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofRef[T](util.Arrays.copyOfRange[T](array, from, until)) } - final class ofByte(val array: Array[Byte]) extends WrappedArrayImpl[Byte] with Serializable { + final class ofByte(val array: Array[Byte]) extends WrappedArray[Byte] with Serializable { def elemTag = ClassTag.Byte def length: Int = array.length def apply(index: Int): Byte = array(index) @@ -163,7 +161,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofByte(util.Arrays.copyOfRange(array, from, until)) } - final class ofShort(val array: Array[Short]) extends WrappedArrayImpl[Short] with Serializable { + final class ofShort(val array: Array[Short]) extends WrappedArray[Short] with Serializable { def elemTag = ClassTag.Short def length: Int = array.length def apply(index: Int): Short = array(index) @@ -172,7 +170,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofShort(util.Arrays.copyOfRange(array, from, until)) } - final class ofChar(val array: Array[Char]) extends WrappedArrayImpl[Char] with Serializable { + final class ofChar(val array: Array[Char]) extends WrappedArray[Char] with Serializable { def elemTag = ClassTag.Char def length: Int = array.length def apply(index: Int): Char = array(index) @@ -181,7 +179,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofChar(util.Arrays.copyOfRange(array, from, until)) } - final class ofInt(val array: Array[Int]) extends WrappedArrayImpl[Int] with Serializable { + final class ofInt(val array: Array[Int]) extends WrappedArray[Int] with Serializable { def elemTag = ClassTag.Int def length: Int = array.length def apply(index: Int): Int = array(index) @@ -190,7 +188,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofInt(util.Arrays.copyOfRange(array, from, until)) } - final class ofLong(val array: Array[Long]) extends WrappedArrayImpl[Long] with Serializable { + final class ofLong(val array: Array[Long]) extends WrappedArray[Long] with Serializable { def elemTag = ClassTag.Long def length: Int = array.length def apply(index: Int): Long = array(index) @@ -199,7 +197,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofLong(util.Arrays.copyOfRange(array, from, until)) } - final class ofFloat(val array: Array[Float]) extends WrappedArrayImpl[Float] with Serializable { + final class ofFloat(val array: Array[Float]) extends WrappedArray[Float] with Serializable { def elemTag = ClassTag.Float def length: Int = array.length def apply(index: Int): Float = array(index) @@ -208,7 +206,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofFloat(util.Arrays.copyOfRange(array, from, until)) } - final class ofDouble(val array: Array[Double]) extends WrappedArrayImpl[Double] with Serializable { + final class ofDouble(val array: Array[Double]) extends WrappedArray[Double] with Serializable { def elemTag = ClassTag.Double def length: Int = array.length def apply(index: Int): Double = array(index) @@ -217,7 +215,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofDouble(util.Arrays.copyOfRange(array, from, until)) } - final class ofBoolean(val array: Array[Boolean]) extends WrappedArrayImpl[Boolean] with Serializable { + final class ofBoolean(val array: Array[Boolean]) extends WrappedArray[Boolean] with Serializable { def elemTag = ClassTag.Boolean def length: Int = array.length def apply(index: Int): Boolean = array(index) @@ -226,7 +224,7 @@ object WrappedArray { protected override def sliceImpl(from: Int, until: Int) = new ofBoolean(util.Arrays.copyOfRange(array, from, until)) } - final class ofUnit(val array: Array[Unit]) extends WrappedArrayImpl[Unit] with Serializable { + final class ofUnit(val array: Array[Unit]) extends WrappedArray[Unit] with Serializable { def elemTag = ClassTag.Unit def length: Int = array.length def apply(index: Int): Unit = array(index) -- cgit v1.2.3 From fe20cce42b879cdc25bd31af2b55091794cc11be Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 3 Apr 2017 12:38:05 -0700 Subject: Revert "Optimised implementation of List.filter/filterNot" This reverts commit eb5c51383a63c5c3420e53ef021607ff5fd20296. --- bincompat-forward.whitelist.conf | 17 ---- .../immutable/FilteredTraversableInternal.scala | 104 --------------------- src/library/scala/collection/immutable/List.scala | 2 - .../scala/reflect/runtime/JavaUniverseForce.scala | 2 +- test/files/run/repl-colon-type.check | 8 +- 5 files changed, 5 insertions(+), 128 deletions(-) delete mode 100644 src/library/scala/collection/immutable/FilteredTraversableInternal.scala diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index 1db1e2f408..023e3bddac 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -924,23 +924,6 @@ filter { { matchName="scala.collection.mutable.ArrayOps#ofFloat.emptyImpl" problemName=DirectMissingMethodProblem - }, - // introduce FilteredTraversableInternal - { - matchName="scala.collection.immutable.Nil$" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.immutable.FilteredTraversableInternal" - problemName=MissingClassProblem - }, - { - matchName="scala.collection.immutable.List" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.immutable.$colon$colon" - problemName=MissingTypesProblem } ] } diff --git a/src/library/scala/collection/immutable/FilteredTraversableInternal.scala b/src/library/scala/collection/immutable/FilteredTraversableInternal.scala deleted file mode 100644 index 35585b7826..0000000000 --- a/src/library/scala/collection/immutable/FilteredTraversableInternal.scala +++ /dev/null @@ -1,104 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala -package collection -package immutable - -import scala.annotation.tailrec - -/** - * Optimised filter functions for List - * n.b. this is an internal class to help maintain compatibility and should not be used directly. - */ -private[immutable] trait FilteredTraversableInternal[+A, +Repr <: AnyRef with TraversableLike[A, Repr]] extends TraversableLike[A, Repr] { - - // Optimized for List - - override def filter(p: A => Boolean): Self = filterImpl(p, isFlipped = false) - - override def filterNot(p: A => Boolean): Self = filterImpl(p, isFlipped = true) - - private[this] def filterImpl(p: A => Boolean, isFlipped: Boolean): Self = { - - // everything seen so far so far is not included - @tailrec def noneIn(l: Repr): Repr = { - if (l.isEmpty) - Nil.asInstanceOf[Repr] - else { - val h = l.head - val t = l.tail - if (p(h) != isFlipped) - allIn(l, t) - else - noneIn(t) - } - } - - // everything from 'start' is included, if everything from this point is in we can return the origin - // start otherwise if we discover an element that is out we must create a new partial list. - @tailrec def allIn(start: Repr, remaining: Repr): Repr = { - if (remaining.isEmpty) - start - else { - val x = remaining.head - if (p(x) != isFlipped) - allIn(start, remaining.tail) - else - partialFill(start, remaining) - } - } - - // we have seen elements that should be included then one that should be excluded, start building - def partialFill(origStart: Repr, firstMiss: Repr): Repr = { - val newHead = new ::(origStart.head, Nil) - var toProcess = origStart.tail - var currentLast = newHead - - // we know that all elements are :: until at least firstMiss.tail - while (!(toProcess eq firstMiss)) { - val newElem = new ::(toProcess.head, Nil) - currentLast.tl = newElem - currentLast = newElem - toProcess = toProcess.tail - } - - // at this point newHead points to a list which is a duplicate of all the 'in' elements up to the first miss. - // currentLast is the last element in that list. - - // now we are going to try and share as much of the tail as we can, only moving elements across when we have to. - var next = firstMiss.tail - var nextToCopy = next // the next element we would need to copy to our list if we cant share. - while (!next.isEmpty) { - // generally recommended is next.isNonEmpty but this incurs an extra method call. - val head: A = next.head - if (p(head) != isFlipped) { - next = next.tail - } else { - // its not a match - do we have outstanding elements? - while (!(nextToCopy eq next)) { - val newElem = new ::(nextToCopy.head, Nil) - currentLast.tl = newElem - currentLast = newElem - nextToCopy = nextToCopy.tail - } - nextToCopy = next.tail - next = next.tail - } - } - - // we have remaining elements - they are unchanged attach them to the end - if (!nextToCopy.isEmpty) - currentLast.tl = nextToCopy.asInstanceOf[List[A]] - - newHead.asInstanceOf[Repr] - } - - noneIn(repr) - } -} \ No newline at end of file diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index e878f49c32..8e8bf953f3 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -86,7 +86,6 @@ sealed abstract class List[+A] extends AbstractSeq[A] with Product with GenericTraversableTemplate[A, List] with LinearSeqOptimized[A, List[A]] - with FilteredTraversableInternal[A, List[A]] with Serializable { override def companion: GenericCompanion[List] = List @@ -417,7 +416,6 @@ sealed abstract class List[+A] extends AbstractSeq[A] // Create a proxy for Java serialization that allows us to avoid mutation // during de-serialization. This is the Serialization Proxy Pattern. protected final def writeReplace(): AnyRef = new List.SerializationProxy(this) - } /** The empty list. diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala index f72b027a2e..45dd550e3e 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala @@ -442,8 +442,8 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => definitions.DoubleTpe definitions.BooleanTpe definitions.ScalaNumericValueClasses - definitions.ScalaValueClasses definitions.ScalaValueClassesNoUnit + definitions.ScalaValueClasses uncurry.VarargsSymbolAttachment uncurry.DesugaredParameterType diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index ca8bd0648d..21fbe34d96 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -75,7 +75,7 @@ TypeRef( ) TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -142,7 +142,7 @@ TypeRef( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -175,7 +175,7 @@ PolyType( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) @@ -198,7 +198,7 @@ PolyType( params = List(TermSymbol(x: T), TermSymbol(y: List[U])) resultType = TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(U >: T))) -- cgit v1.2.3 From 73c9693c8aced6945b75faa5e3765b7bc6ec21e9 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 3 Apr 2017 12:38:45 -0700 Subject: Revert "Optimize slice and take in ArrayOps, WrappedArray" This reverts commit d540bf01fe4d9e5c56a68b0d3bada9d97af77e3f. --- bincompat-backward.whitelist.conf | 41 --- bincompat-forward.whitelist.conf | 296 --------------------- .../scala/collection/mutable/ArrayOps.scala | 74 +----- .../scala/collection/mutable/WrappedArray.scala | 49 ---- 4 files changed, 10 insertions(+), 450 deletions(-) diff --git a/bincompat-backward.whitelist.conf b/bincompat-backward.whitelist.conf index 7303e8d80f..0770b3cb95 100644 --- a/bincompat-backward.whitelist.conf +++ b/bincompat-backward.whitelist.conf @@ -223,47 +223,6 @@ filter { { matchName="scala.concurrent.impl.Promise.toString" problemName=MissingMethodProblem - }, - // https://github.com/scala/scala/pull/5652 - { - matchName="scala.collection.mutable.ArrayOps#ofChar.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofShort.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofUnit.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofInt.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofBoolean.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofDouble.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofRef.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofByte.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofLong.slice" - problemName=FinalMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofFloat.slice" - problemName=FinalMethodProblem } ] } diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index 023e3bddac..7f28a718bd 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -628,302 +628,6 @@ filter { { matchName="scala.reflect.api.SerializedTypeTag.serialVersionUID" problemName=MissingFieldProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofChar" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofChar.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofChar.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofShort" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofShort.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofShort.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofByte.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofByte.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofBoolean.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofBoolean.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofChar.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofChar.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofDouble.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofDouble.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofUnit" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofUnit.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofUnit.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofInt.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofInt.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofInt" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofInt.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofInt.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofRef.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofRef.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofChar.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofChar.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofUnit.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofUnit.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofBoolean" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofBoolean.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofBoolean.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofShort.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofShort.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofShort.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofShort.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray.slice" - problemName=IncompatibleResultTypeProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofRef.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofRef.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofUnit.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofUnit.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofByte.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofByte.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofDouble.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofDouble.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOpsImpl" - problemName=MissingClassProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofInt.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofInt.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofDouble" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofDouble.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofDouble.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofRef" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofRef.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofRef.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofLong.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofLong.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofByte" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofByte.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofByte.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofFloat.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofFloat.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofLong.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofLong.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofBoolean.sliceImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofBoolean.emptyImpl$extension" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofFloat.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.WrappedArray#ofFloat.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofLong" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofLong.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofLong.emptyImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps$ofFloat" - problemName=MissingTypesProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofFloat.sliceImpl" - problemName=DirectMissingMethodProblem - }, - { - matchName="scala.collection.mutable.ArrayOps#ofFloat.emptyImpl" - problemName=DirectMissingMethodProblem } ] } diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index 04bb1074ea..00491ef20e 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -10,8 +10,6 @@ package scala package collection package mutable -import java.util - import scala.compat.Platform.arraycopy import scala.reflect.ClassTag import scala.runtime.ScalaRunTime._ @@ -177,23 +175,6 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza } -/** to provide binary compat for 2.11 and 2.12 this class contains - * functionality that should be migrated to ArrayOps in 2.13 - * - */ -private[mutable] sealed trait ArrayOpsImpl[T] extends Any with ArrayOps[T] { - override final def slice(from: Int, until: Int): Array[T] = { - val start = if (from < 0) 0 else from - if (until <= start || start >= repr.length) - return emptyImpl - val end = if (until > length) length else until - sliceImpl(start, end) - } - protected def emptyImpl: Array[T] - protected def sliceImpl(from: Int, until: Int): Array[T] - -} - /** * A companion object for `ArrayOps`. * @@ -201,24 +182,12 @@ private[mutable] sealed trait ArrayOpsImpl[T] extends Any with ArrayOps[T] { */ object ArrayOps { - private val emptyByteArray = new Array[Byte](0) - private val emptyShortArray = new Array[Short](0) - private val emptyIntArray = new Array[Int](0) - private val emptyLongArray = new Array[Long](0) - private val emptyFloatArray = new Array[Float](0) - private val emptyDoubleArray = new Array[Double](0) - private val emptyUnitArray = new Array[Unit](0) - private val emptyCharArray = new Array[Char](0) - private val emptyBooleanArray = new Array[Boolean](0) - /** A class of `ArrayOps` for arrays containing reference types. */ - final class ofRef[T <: AnyRef](override val repr: Array[T]) extends AnyVal with ArrayOpsImpl[T] with ArrayLike[T, Array[T]] { + final class ofRef[T <: AnyRef](override val repr: Array[T]) extends AnyVal with ArrayOps[T] with ArrayLike[T, Array[T]] { override protected[this] def thisCollection: WrappedArray[T] = new WrappedArray.ofRef[T](repr) override protected[this] def toCollection(repr: Array[T]): WrappedArray[T] = new WrappedArray.ofRef[T](repr) override protected[this] def newBuilder = new ArrayBuilder.ofRef[T]()(ClassTag[T](arrayElementClass(repr.getClass))) - protected override def emptyImpl:Array[T] = util.Arrays.copyOf[T](repr,0) - protected override def sliceImpl(from: Int, until: Int): Array[T] = util.Arrays.copyOfRange[T](repr, from, until) def length: Int = repr.length def apply(index: Int): T = repr(index) @@ -226,13 +195,11 @@ object ArrayOps { } /** A class of `ArrayOps` for arrays containing `byte`s. */ -final class ofByte(override val repr: Array[Byte]) extends AnyVal with ArrayOpsImpl[Byte] with ArrayLike[Byte, Array[Byte]] { +final class ofByte(override val repr: Array[Byte]) extends AnyVal with ArrayOps[Byte] with ArrayLike[Byte, Array[Byte]] { override protected[this] def thisCollection: WrappedArray[Byte] = new WrappedArray.ofByte(repr) override protected[this] def toCollection(repr: Array[Byte]): WrappedArray[Byte] = new WrappedArray.ofByte(repr) override protected[this] def newBuilder = new ArrayBuilder.ofByte - protected override def emptyImpl = emptyByteArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Byte = repr(index) @@ -240,13 +207,11 @@ final class ofByte(override val repr: Array[Byte]) extends AnyVal with ArrayOpsI } /** A class of `ArrayOps` for arrays containing `short`s. */ -final class ofShort(override val repr: Array[Short]) extends AnyVal with ArrayOpsImpl[Short] with ArrayLike[Short, Array[Short]] { +final class ofShort(override val repr: Array[Short]) extends AnyVal with ArrayOps[Short] with ArrayLike[Short, Array[Short]] { override protected[this] def thisCollection: WrappedArray[Short] = new WrappedArray.ofShort(repr) override protected[this] def toCollection(repr: Array[Short]): WrappedArray[Short] = new WrappedArray.ofShort(repr) override protected[this] def newBuilder = new ArrayBuilder.ofShort - protected override def emptyImpl = emptyShortArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Short = repr(index) @@ -254,13 +219,11 @@ final class ofShort(override val repr: Array[Short]) extends AnyVal with ArrayOp } /** A class of `ArrayOps` for arrays containing `char`s. */ -final class ofChar(override val repr: Array[Char]) extends AnyVal with ArrayOpsImpl[Char] with ArrayLike[Char, Array[Char]] { +final class ofChar(override val repr: Array[Char]) extends AnyVal with ArrayOps[Char] with ArrayLike[Char, Array[Char]] { override protected[this] def thisCollection: WrappedArray[Char] = new WrappedArray.ofChar(repr) override protected[this] def toCollection(repr: Array[Char]): WrappedArray[Char] = new WrappedArray.ofChar(repr) override protected[this] def newBuilder = new ArrayBuilder.ofChar - protected override def emptyImpl = emptyCharArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Char = repr(index) @@ -268,13 +231,11 @@ final class ofChar(override val repr: Array[Char]) extends AnyVal with ArrayOpsI } /** A class of `ArrayOps` for arrays containing `int`s. */ -final class ofInt(override val repr: Array[Int]) extends AnyVal with ArrayOpsImpl[Int] with ArrayLike[Int, Array[Int]] { +final class ofInt(override val repr: Array[Int]) extends AnyVal with ArrayOps[Int] with ArrayLike[Int, Array[Int]] { override protected[this] def thisCollection: WrappedArray[Int] = new WrappedArray.ofInt(repr) override protected[this] def toCollection(repr: Array[Int]): WrappedArray[Int] = new WrappedArray.ofInt(repr) override protected[this] def newBuilder = new ArrayBuilder.ofInt - protected override def emptyImpl = emptyIntArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Int = repr(index) @@ -282,13 +243,11 @@ final class ofInt(override val repr: Array[Int]) extends AnyVal with ArrayOpsImp } /** A class of `ArrayOps` for arrays containing `long`s. */ -final class ofLong(override val repr: Array[Long]) extends AnyVal with ArrayOpsImpl[Long] with ArrayLike[Long, Array[Long]] { +final class ofLong(override val repr: Array[Long]) extends AnyVal with ArrayOps[Long] with ArrayLike[Long, Array[Long]] { override protected[this] def thisCollection: WrappedArray[Long] = new WrappedArray.ofLong(repr) override protected[this] def toCollection(repr: Array[Long]): WrappedArray[Long] = new WrappedArray.ofLong(repr) override protected[this] def newBuilder = new ArrayBuilder.ofLong - protected override def emptyImpl = emptyLongArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Long = repr(index) @@ -296,13 +255,11 @@ final class ofLong(override val repr: Array[Long]) extends AnyVal with ArrayOpsI } /** A class of `ArrayOps` for arrays containing `float`s. */ -final class ofFloat(override val repr: Array[Float]) extends AnyVal with ArrayOpsImpl[Float] with ArrayLike[Float, Array[Float]] { +final class ofFloat(override val repr: Array[Float]) extends AnyVal with ArrayOps[Float] with ArrayLike[Float, Array[Float]] { override protected[this] def thisCollection: WrappedArray[Float] = new WrappedArray.ofFloat(repr) override protected[this] def toCollection(repr: Array[Float]): WrappedArray[Float] = new WrappedArray.ofFloat(repr) override protected[this] def newBuilder = new ArrayBuilder.ofFloat - protected override def emptyImpl = emptyFloatArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Float = repr(index) @@ -310,13 +267,11 @@ final class ofFloat(override val repr: Array[Float]) extends AnyVal with ArrayOp } /** A class of `ArrayOps` for arrays containing `double`s. */ -final class ofDouble(override val repr: Array[Double]) extends AnyVal with ArrayOpsImpl[Double] with ArrayLike[Double, Array[Double]] { +final class ofDouble(override val repr: Array[Double]) extends AnyVal with ArrayOps[Double] with ArrayLike[Double, Array[Double]] { override protected[this] def thisCollection: WrappedArray[Double] = new WrappedArray.ofDouble(repr) override protected[this] def toCollection(repr: Array[Double]): WrappedArray[Double] = new WrappedArray.ofDouble(repr) override protected[this] def newBuilder = new ArrayBuilder.ofDouble - protected override def emptyImpl = emptyDoubleArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Double = repr(index) @@ -324,13 +279,11 @@ final class ofDouble(override val repr: Array[Double]) extends AnyVal with Array } /** A class of `ArrayOps` for arrays containing `boolean`s. */ -final class ofBoolean(override val repr: Array[Boolean]) extends AnyVal with ArrayOpsImpl[Boolean] with ArrayLike[Boolean, Array[Boolean]] { +final class ofBoolean(override val repr: Array[Boolean]) extends AnyVal with ArrayOps[Boolean] with ArrayLike[Boolean, Array[Boolean]] { override protected[this] def thisCollection: WrappedArray[Boolean] = new WrappedArray.ofBoolean(repr) override protected[this] def toCollection(repr: Array[Boolean]): WrappedArray[Boolean] = new WrappedArray.ofBoolean(repr) override protected[this] def newBuilder = new ArrayBuilder.ofBoolean - protected override def emptyImpl = emptyBooleanArray - protected override def sliceImpl(from: Int, until: Int) = util.Arrays.copyOfRange(repr, from, until) def length: Int = repr.length def apply(index: Int): Boolean = repr(index) @@ -338,18 +291,11 @@ final class ofBoolean(override val repr: Array[Boolean]) extends AnyVal with Arr } /** A class of `ArrayOps` for arrays of `Unit` types. */ -final class ofUnit(override val repr: Array[Unit]) extends AnyVal with ArrayOpsImpl[Unit] with ArrayLike[Unit, Array[Unit]] { +final class ofUnit(override val repr: Array[Unit]) extends AnyVal with ArrayOps[Unit] with ArrayLike[Unit, Array[Unit]] { override protected[this] def thisCollection: WrappedArray[Unit] = new WrappedArray.ofUnit(repr) override protected[this] def toCollection(repr: Array[Unit]): WrappedArray[Unit] = new WrappedArray.ofUnit(repr) override protected[this] def newBuilder = new ArrayBuilder.ofUnit - protected override def emptyImpl = emptyUnitArray - protected override def sliceImpl(from: Int, until: Int) = { - // cant use util.Arrays.copyOfRange[Unit](repr, from, until) - Unit is special and doesnt compile - val res = new Array[Unit](until-from) - System.arraycopy(repr, from, res, 0, res.size) - res - } def length: Int = repr.length def apply(index: Int): Unit = repr(index) diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala index 81e0e64fb2..8740bda835 100644 --- a/src/library/scala/collection/mutable/WrappedArray.scala +++ b/src/library/scala/collection/mutable/WrappedArray.scala @@ -72,17 +72,6 @@ extends AbstractSeq[T] else super.toArray[U] } - override def slice(from: Int, until: Int): WrappedArray[T] = { - val start = if (from < 0) 0 else from - if (until <= start || start >= repr.length) - return emptyImpl - val end = if (until > length) length else until - sliceImpl(start, end) - } - //retain existing functionallity for existing implementations outside this file - protected def emptyImpl: WrappedArray[T] = newBuilder.result() - //retain existing functionallity for existing implementations outside this file - protected def sliceImpl(from: Int, until: Int): WrappedArray[T] = super.slice(from, until) override def stringPrefix = "WrappedArray" @@ -99,7 +88,6 @@ extends AbstractSeq[T] /** A companion object used to create instances of `WrappedArray`. */ object WrappedArray { - import java.util // This is reused for all calls to empty. private val EmptyWrappedArray = new ofRef[AnyRef](new Array[AnyRef](0)) def empty[T <: AnyRef]: WrappedArray[T] = EmptyWrappedArray.asInstanceOf[WrappedArray[T]] @@ -133,23 +121,11 @@ object WrappedArray { def newBuilder[A]: Builder[A, IndexedSeq[A]] = new ArrayBuffer - private val emptyWrappedByte = new ofByte(new Array[Byte](0)) - private val emptyWrappedShort = new ofShort(new Array[Short](0)) - private val emptyWrappedInt = new ofInt(new Array[Int](0)) - private val emptyWrappedLong = new ofLong(new Array[Long](0)) - private val emptyWrappedFloat = new ofFloat(new Array[Float](0)) - private val emptyWrappedDouble = new ofDouble(new Array[Double](0)) - private val emptyWrappedUnit = new ofUnit(new Array[Unit](0)) - private val emptyWrappedChar = new ofChar(new Array[Char](0)) - private val emptyWrappedBoolean = new ofBoolean(new Array[Boolean](0)) - final class ofRef[T <: AnyRef](val array: Array[T]) extends WrappedArray[T] with Serializable { lazy val elemTag = ClassTag[T](arrayElementClass(array.getClass)) def length: Int = array.length def apply(index: Int): T = array(index).asInstanceOf[T] def update(index: Int, elem: T) { array(index) = elem } - protected override def emptyImpl = new ofRef(util.Arrays.copyOf[T](array,0)) - protected override def sliceImpl(from: Int, until: Int) = new ofRef[T](util.Arrays.copyOfRange[T](array, from, until)) } final class ofByte(val array: Array[Byte]) extends WrappedArray[Byte] with Serializable { @@ -157,8 +133,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Byte = array(index) def update(index: Int, elem: Byte) { array(index) = elem } - protected override def emptyImpl = emptyWrappedByte - protected override def sliceImpl(from: Int, until: Int) = new ofByte(util.Arrays.copyOfRange(array, from, until)) } final class ofShort(val array: Array[Short]) extends WrappedArray[Short] with Serializable { @@ -166,8 +140,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Short = array(index) def update(index: Int, elem: Short) { array(index) = elem } - protected override def emptyImpl = emptyWrappedShort - protected override def sliceImpl(from: Int, until: Int) = new ofShort(util.Arrays.copyOfRange(array, from, until)) } final class ofChar(val array: Array[Char]) extends WrappedArray[Char] with Serializable { @@ -175,8 +147,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Char = array(index) def update(index: Int, elem: Char) { array(index) = elem } - protected override def emptyImpl = emptyWrappedChar - protected override def sliceImpl(from: Int, until: Int) = new ofChar(util.Arrays.copyOfRange(array, from, until)) } final class ofInt(val array: Array[Int]) extends WrappedArray[Int] with Serializable { @@ -184,8 +154,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Int = array(index) def update(index: Int, elem: Int) { array(index) = elem } - protected override def emptyImpl = emptyWrappedInt - protected override def sliceImpl(from: Int, until: Int) = new ofInt(util.Arrays.copyOfRange(array, from, until)) } final class ofLong(val array: Array[Long]) extends WrappedArray[Long] with Serializable { @@ -193,8 +161,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Long = array(index) def update(index: Int, elem: Long) { array(index) = elem } - protected override def emptyImpl = emptyWrappedLong - protected override def sliceImpl(from: Int, until: Int) = new ofLong(util.Arrays.copyOfRange(array, from, until)) } final class ofFloat(val array: Array[Float]) extends WrappedArray[Float] with Serializable { @@ -202,8 +168,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Float = array(index) def update(index: Int, elem: Float) { array(index) = elem } - protected override def emptyImpl = emptyWrappedFloat - protected override def sliceImpl(from: Int, until: Int) = new ofFloat(util.Arrays.copyOfRange(array, from, until)) } final class ofDouble(val array: Array[Double]) extends WrappedArray[Double] with Serializable { @@ -211,8 +175,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Double = array(index) def update(index: Int, elem: Double) { array(index) = elem } - protected override def emptyImpl = emptyWrappedDouble - protected override def sliceImpl(from: Int, until: Int) = new ofDouble(util.Arrays.copyOfRange(array, from, until)) } final class ofBoolean(val array: Array[Boolean]) extends WrappedArray[Boolean] with Serializable { @@ -220,8 +182,6 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Boolean = array(index) def update(index: Int, elem: Boolean) { array(index) = elem } - protected override def emptyImpl = emptyWrappedBoolean - protected override def sliceImpl(from: Int, until: Int) = new ofBoolean(util.Arrays.copyOfRange(array, from, until)) } final class ofUnit(val array: Array[Unit]) extends WrappedArray[Unit] with Serializable { @@ -229,14 +189,5 @@ object WrappedArray { def length: Int = array.length def apply(index: Int): Unit = array(index) def update(index: Int, elem: Unit) { array(index) = elem } - protected override def emptyImpl = emptyWrappedUnit - protected override def sliceImpl(from: Int, until: Int) = { - // cant use - // new ofUnit(util.Arrays.copyOfRange[Unit](array, from, until)) - Unit is special and doesnt compile - // cant use util.Arrays.copyOfRange[Unit](repr, from, until) - Unit is special and doesnt compile - val res = new Array[Unit](until-from) - System.arraycopy(repr, from, res, 0, until-from) - new ofUnit(res) - } } } -- cgit v1.2.3 From b722e61682807772093cc499415d58a76fc2d0ab Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 4 Apr 2017 17:30:00 -0700 Subject: `CompleterWrapper` delegates `typeParams`. Fixes the problem reported with #5730 by xuwei-k in scala/scala-dev#352. --- src/compiler/scala/tools/nsc/typechecker/Namers.scala | 3 +++ test/files/pos/userdefined_apply_poly_overload.scala | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/files/pos/userdefined_apply_poly_overload.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 69b8cb12e6..b755ee3ebd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -611,6 +611,9 @@ trait Namers extends MethodSynthesis { } class CompleterWrapper(completer: TypeCompleter) extends TypeCompleter { + // override important when completer.isInstanceOf[PolyTypeCompleter]! + override val typeParams = completer.typeParams + val tree = completer.tree override def complete(sym: Symbol): Unit = { diff --git a/test/files/pos/userdefined_apply_poly_overload.scala b/test/files/pos/userdefined_apply_poly_overload.scala new file mode 100644 index 0000000000..6760c1424f --- /dev/null +++ b/test/files/pos/userdefined_apply_poly_overload.scala @@ -0,0 +1,13 @@ +object Foo { + // spurious error if: + // - this definition precedes that of apply (which is overloaded with the synthetic one derived from the case class) + // - AND `Foo.apply` is explicitly applied to `[A]` (no error if `[A]` is inferred) + // + def referToPolyOverloadedApply[A]: Foo[A] = Foo.apply[A]("bla") + // ^ + // found : String("bla") + // required: Int + + def apply[A](x: Int): Foo[A] = ??? +} +case class Foo[A](x: String) // must be polymorphic -- cgit v1.2.3 From 7fa382355493354292fe5356bb4e6c72f56f43b9 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 7 Apr 2017 07:37:47 -0700 Subject: Bye bye JIRA --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c2891390d4..d4babc4642 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,7 @@ In order to get in touch with Scala contributors, join the # Reporting issues -We're still using Jira for issue reporting, so please [report any issues](https://issues.scala-lang.org) over there. -(We would love to start using GitHub Issues, but we're too resource-constrained to take on this migration right now.) +Please report bugs at the [scala/bug issue tracker](https://github.com/scala/bug/issues). We use the [scala/scala-dev tracker](https://github.com/scala/scala-dev/issues) for coordinating bigger work items. # Get in touch! If you need some help with your PR at any time, please feel free to @-mention anyone from the list below, and we will do our best to help you out: -- cgit v1.2.3