Skip to content

Commit 63081ac

Browse files
committed
Placeholders
Calculate Global PipelineMain Reporting Trees PerRunInit AliasingAnalyzer CallGraph CopyProp Inliner LocalOpt ZipAndJarFileLookupFactory Jar More
1 parent 4d87a1c commit 63081ac

File tree

9 files changed

+32
-19
lines changed

9 files changed

+32
-19
lines changed

library/src/scala/collection/ArrayOps.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,8 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
14781478
/** Create a copy of this array with the specified element type. */
14791479
def toArray[B >: A: ClassTag]: Array[B] = {
14801480
val destination = new Array[B](xs.length)
1481-
copyToArray(destination, 0)
1481+
val copied = copyToArray(destination, 0)
1482+
assert(copied == xs.length)
14821483
destination
14831484
}
14841485

library/src/scala/collection/IterableOnce.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,9 +1328,9 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
13281328
def toIndexedSeq: immutable.IndexedSeq[A] = immutable.IndexedSeq.from(this)
13291329

13301330
@deprecated("Use .to(LazyList) instead of .toStream", "2.13.0")
1331-
@`inline` final def toStream: immutable.Stream[A] = to(immutable.Stream)
1331+
@inline final def toStream: immutable.Stream[A] = to(immutable.Stream)
13321332

1333-
@`inline` final def toBuffer[B >: A]: mutable.Buffer[B] = mutable.Buffer.from(this)
1333+
@inline final def toBuffer[B >: A]: mutable.Buffer[B] = mutable.Buffer.from(this)
13341334

13351335
/** Convert collection to array.
13361336
*
@@ -1339,7 +1339,8 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
13391339
def toArray[B >: A: ClassTag]: Array[B] =
13401340
if (knownSize >= 0) {
13411341
val destination = new Array[B](knownSize)
1342-
copyToArray(destination, 0)
1342+
val copied = copyToArray(destination, 0)
1343+
assert(copied == destination.length)
13431344
destination
13441345
}
13451346
else mutable.ArrayBuilder.make[B].addAll(this).result()

library/src/scala/collection/Seq.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,8 @@ trait SeqOps[+A, +CC[_], +C] extends Any
723723
else if (len > 1) {
724724
b.sizeHint(len)
725725
val arr = new Array[Any](len)
726-
copyToArray(arr)
726+
val copied = copyToArray(arr)
727+
assert(copied == len)
727728
java.util.Arrays.sort(arr.asInstanceOf[Array[AnyRef]], ord.asInstanceOf[Ordering[AnyRef]])
728729
var i = 0
729730
while (i < len) {

library/src/scala/collection/SeqView.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ object SeqView {
163163
else if (len == 1) List(underlying.head)
164164
else {
165165
val arr = new Array[Any](len) // Array[Any] =:= Array[AnyRef]
166-
underlying.copyToArray(arr)
166+
val copied = underlying.copyToArray(arr)
167+
assert(copied == len)
167168
java.util.Arrays.sort(arr.asInstanceOf[Array[AnyRef]], ord.asInstanceOf[Ordering[AnyRef]])
168169
// casting the Array[AnyRef] to Array[A] and creating an ArraySeq from it
169170
// is safe because:

library/src/scala/collection/immutable/LazyList.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ final class LazyList[+A] private(private[this] var lazyState: () => LazyList.Sta
853853
sb
854854
}
855855

856-
private[this] def addStringNoForce(b: JStringBuilder, start: String, sep: String, end: String): JStringBuilder = {
856+
private[this] def addStringNoForce(b: JStringBuilder, start: String, sep: String, end: String): b.type = {
857857
b.append(start)
858858
if (!stateDefined) b.append("<not computed>")
859859
else if (!isEmpty) {
@@ -917,6 +917,7 @@ final class LazyList[+A] private(private[this] var lazyState: () => LazyList.Sta
917917
}
918918
}
919919
b.append(end)
920+
b
920921
}
921922

922923
/** $preservesLaziness

library/src/scala/collection/immutable/RedBlackTree.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ private[collection] object RedBlackTree {
567567
override def toString: String = s"${if(isRed) "RedTree" else "BlackTree"}($key, $value, $left, $right)"
568568

569569
//mutable APIs
570-
private[RedBlackTree] def makeImmutable: Tree[A, B] = {
571-
def makeImmutableImpl() = {
570+
private[RedBlackTree] def makeImmutable: this.type = {
571+
def makeImmutableImpl(): Unit = {
572572
if (isMutable) {
573573
var size = 1
574574
if (_left ne null) {
@@ -581,7 +581,6 @@ private[collection] object RedBlackTree {
581581
}
582582
_count |= size //retains colour
583583
}
584-
this
585584
}
586585
makeImmutableImpl()
587586
this

library/src/scala/collection/immutable/Stream.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ sealed abstract class Stream[+A] extends AbstractSeq[A]
242242
sb
243243
}
244244

245-
private[this] def addStringNoForce(b: JStringBuilder, start: String, sep: String, end: String): JStringBuilder = {
245+
private[this] def addStringNoForce(b: JStringBuilder, start: String, sep: String, end: String): b.type = {
246246
b.append(start)
247247
if (nonEmpty) {
248248
b.append(head)
@@ -311,6 +311,7 @@ sealed abstract class Stream[+A] extends AbstractSeq[A]
311311
}
312312
}
313313
b.append(end)
314+
b
314315
}
315316

316317
/**

library/src/scala/collection/immutable/Vector.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ object Vector extends StrictOptimizedSeqFactory[Vector] {
4747
as.unsafeArray.asInstanceOf[Arr1]
4848
case it: Iterable[E] =>
4949
val a1 = new Arr1(knownSize)
50-
it.copyToArray(a1.asInstanceOf[Array[Any]])
50+
val copied = it.copyToArray(a1.asInstanceOf[Array[Any]])
51+
assert(copied == knownSize)
5152
a1
5253
case _ =>
5354
val a1 = new Arr1(knownSize)
54-
it.iterator.copyToArray(a1.asInstanceOf[Array[Any]])
55+
val copied = it.iterator.copyToArray(a1.asInstanceOf[Array[Any]])
56+
assert(copied == knownSize)
5557
a1.asInstanceOf[Arr1]
5658
}
5759
new Vector1[E](a1)
@@ -2192,7 +2194,8 @@ private object VectorStatics {
21922194
case s =>
21932195
val prefix1b = new Arr1(prefix1.length + s)
21942196
System.arraycopy(prefix1, 0, prefix1b, s, prefix1.length)
2195-
it.copyToArray(prefix1b.asInstanceOf[Array[Any]], 0)
2197+
val copied = it.copyToArray(prefix1b.asInstanceOf[Array[Any]], 0)
2198+
assert(copied == s)
21962199
prefix1b
21972200
}
21982201
} else null
@@ -2201,7 +2204,8 @@ private object VectorStatics {
22012204
if(s > 0 && s <= WIDTH-prefix1.length) {
22022205
val prefix1b = new Arr1(prefix1.length + s)
22032206
System.arraycopy(prefix1, 0, prefix1b, s, prefix1.length)
2204-
it.iterator.copyToArray(prefix1b.asInstanceOf[Array[Any]], 0)
2207+
val copied = it.iterator.copyToArray(prefix1b.asInstanceOf[Array[Any]], 0)
2208+
assert(copied == s)
22052209
prefix1b
22062210
} else null
22072211
}
@@ -2214,15 +2218,17 @@ private object VectorStatics {
22142218
case 1 => copyAppend(suffix1, it.head.asInstanceOf[AnyRef])
22152219
case s =>
22162220
val suffix1b = copyOf(suffix1, suffix1.length + s)
2217-
it.copyToArray(suffix1b.asInstanceOf[Array[Any]], suffix1.length)
2221+
val copied = it.copyToArray(suffix1b.asInstanceOf[Array[Any]], suffix1.length)
2222+
assert(copied == s)
22182223
suffix1b
22192224
}
22202225
} else null
22212226
case it =>
22222227
val s = it.knownSize
22232228
if(s > 0 && s <= WIDTH-suffix1.length) {
22242229
val suffix1b = copyOf(suffix1, suffix1.length + s)
2225-
it.iterator.copyToArray(suffix1b.asInstanceOf[Array[Any]], suffix1.length)
2230+
val copied = it.iterator.copyToArray(suffix1b.asInstanceOf[Array[Any]], suffix1.length)
2231+
assert(copied == s)
22262232
suffix1b
22272233
} else null
22282234
}

library/src/scala/collection/mutable/ArrayDeque.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class ArrayDeque[A] protected (
112112
case srcLength if mustGrow(srcLength + n) =>
113113
val finalLength = srcLength + n
114114
val array2 = ArrayDeque.alloc(finalLength)
115-
it.copyToArray(array2.asInstanceOf[Array[A]])
115+
val copied = it.copyToArray(array2.asInstanceOf[Array[A]])
116+
assert(copied == srcLength)
116117
copySliceToArray(srcStart = 0, dest = array2, destStart = srcLength, maxItems = n)
117118
reset(array = array2, start = 0, end = finalLength)
118119

@@ -199,7 +200,8 @@ class ArrayDeque[A] protected (
199200
if (mustGrow(finalLength)) {
200201
val array2 = ArrayDeque.alloc(finalLength)
201202
copySliceToArray(srcStart = 0, dest = array2, destStart = 0, maxItems = idx)
202-
it.copyToArray(array2.asInstanceOf[Array[A]], idx)
203+
val copied = it.copyToArray(array2.asInstanceOf[Array[A]], idx)
204+
assert(copied == srcLength)
203205
copySliceToArray(srcStart = idx, dest = array2, destStart = idx + srcLength, maxItems = n)
204206
reset(array = array2, start = 0, end = finalLength)
205207
} else if (2*idx >= n) { // Cheaper to shift the suffix right

0 commit comments

Comments
 (0)