Skip to content

Commit 959e4d5

Browse files
authored
Merge pull request #768 from satorg/fix-core-warnings
Fix warnings in `core` module
2 parents abe3bc6 + 3932259 commit 959e4d5

File tree

8 files changed

+22
-19
lines changed

8 files changed

+22
-19
lines changed

core/src/main/scala/cats/collections/BitSet.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ object BitSet {
559559
BitSet.adoptedUnion(this, rhs)
560560
} else {
561561
// height == rhs.height, so we know rhs is a Branch.
562-
val Branch(_, _, rcs) = rhs
562+
val Branch(_, _, rcs) = rhs: @unchecked
563563
val cs = new Array[BitSet](32)
564564
var i = 0
565565
while (i < 32) {
@@ -591,7 +591,7 @@ object BitSet {
591591
Empty
592592
} else {
593593
// height == rhs.height, so we know rhs is a Branch.
594-
val Branch(_, _, rcs) = rhs
594+
val Branch(_, _, rcs) = rhs: @unchecked
595595
val cs = new Array[BitSet](32)
596596
var i = 0
597597
var nonEmpty = false
@@ -629,7 +629,7 @@ object BitSet {
629629
false
630630
} else {
631631
// height == rhs.height, so we know rhs is a Branch.
632-
val Branch(_, _, rcs) = rhs
632+
val Branch(_, _, rcs) = rhs: @unchecked
633633
var i = 0
634634
while (i < 32) {
635635
val x = children(i)
@@ -674,7 +674,7 @@ object BitSet {
674674
this | rhs
675675
} else {
676676
// height == rhs.height, so we know rhs is a Branch.
677-
val Branch(_, _, rcs) = rhs
677+
val Branch(_, _, rcs) = rhs: @unchecked
678678
val cs = new Array[BitSet](32)
679679
var i = 0
680680
while (i < 32) {
@@ -791,7 +791,7 @@ object BitSet {
791791
throw InternalError("branch misaligned")
792792
} else {
793793
// height == rhs.height, so we know rhs is a Branch.
794-
val Branch(_, _, rcs) = rhs
794+
val Branch(_, _, rcs) = rhs: @unchecked
795795
var i = 0
796796
while (i < 32) {
797797
val x = children(i)

core/src/main/scala/cats/collections/Dequeue.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ sealed abstract class Dequeue[+A] {
233233
SingletonDequeue(a)
234234
else
235235
FullDequeue(NonEmptyList(a, List.empty), 1, bl.toList.asInstanceOf[NonEmptyList[B]], bs - 1)
236-
case (Some(f), Some(b)) =>
237-
fl += f
236+
case (Some(ff), Some(b)) =>
237+
fl += ff
238238
bl += b
239239
FullDequeue(fl.toList.asInstanceOf[NonEmptyList[B]],
240240
fs,

core/src/main/scala/cats/collections/DisjointSets.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ class DisjointSets[T: Order] private (private val entries: AvlMap[T, Entry[T]])
113113
*/
114114
def toSets: (DisjointSets[T], AvlMap[T, AvlSet[T]]) =
115115
entries.foldLeft((this, AvlMap[T, AvlSet[T]]())) { case ((dsets, acc), (k, _)) =>
116-
val (newSt, Some(label)) = dsets.find(k)
116+
// Each `k` is from the `entries`` map, so it must be found.
117+
val (newSt, Some(label)) = dsets.find(k): @unchecked
117118
val updatedSet = acc.get(label).getOrElse(AvlSet.empty[T]) + k
118119
(newSt, acc + (label -> updatedSet))
119120
}

core/src/main/scala/cats/collections/Heap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ object Heap {
392392
val sb = new java.lang.StringBuilder
393393
sb.append("Heap(")
394394
f.foldLeft(false) { (notFirst, a) =>
395-
if (notFirst) sb.append(", ")
395+
if (notFirst) sb.append(", "): Unit
396396
sb.append(s.show(a))
397397
true
398398
}

core/src/main/scala/cats/collections/Map.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ trait AvlMapInstances {
173173

174174
override def tailRecM[A, B](a: A)(f: A => AvlMap[K, Either[A, B]]): AvlMap[K, B] = {
175175
@tailrec def extract(kv: (K, Either[A, B])): AvlSet[(K, B)] = kv._2 match {
176-
case Left(a) =>
177-
f(a).get(kv._1) match {
176+
case Left(aa) =>
177+
f(aa).get(kv._1) match {
178178
case Some(x) => extract(kv._1 -> x)
179179
case _ => AvlSet.empty[(K, B)]
180180
}

core/src/main/scala/cats/collections/PairingHeap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ object PairingHeap {
336336
val sb = new java.lang.StringBuilder
337337
sb.append("PairingHeap(")
338338
f.foldLeft(false) { (notFirst, a) =>
339-
if (notFirst) sb.append(", ")
339+
if (notFirst) sb.append(", "): Unit
340340
sb.append(s.show(a))
341341
true
342342
}

core/src/main/scala/cats/collections/Set.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ object AvlSet extends AvlSetInstances {
376376
left match {
377377
case Branch(lv, ll, lr) =>
378378
if (rotation(ll.height, lr.height, 0) < 0) {
379-
val Branch(lrv, lrl, lrr) = lr
379+
// If `lr` is taller than `ll`, then `lr` cannot be empty.
380+
val Branch(lrv, lrl, lrr) = lr: @unchecked
380381
Branch(lrv, Branch(lv, ll, lrl), Branch(value, lrr, right))
381382
} else {
382383
Branch(lv, ll, Branch(value, lr, right))
@@ -387,7 +388,8 @@ object AvlSet extends AvlSetInstances {
387388
right match {
388389
case Branch(rv, rl, rr) =>
389390
if (rotation(rl.height, rr.height, 0) > 0) {
390-
val Branch(rlv, rll, rlr) = rl
391+
// If `rl` is taller than `rr`, then `rl` cannot be empty.
392+
val Branch(rlv, rll, rlr) = rl: @unchecked
391393
Branch(rlv, Branch(value, left, rll), Branch(rv, rlr, rr))
392394
} else {
393395
Branch(rv, Branch(value, left, rl), rr)

core/src/main/scala/cats/collections/TreeList.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ sealed abstract class TreeList[+A] {
199199
l.uncons match {
200200
case None => ()
201201
case Some((h, t)) =>
202-
if (!first) strb.append(", ")
202+
if (!first) strb.append(", "): Unit
203203
strb.append(h.toString)
204204
loop(false, t)
205205
}
@@ -807,7 +807,7 @@ object TreeList extends TreeListInstances0 {
807807
fa match {
808808
case NonEmpty(_, tail) =>
809809
loop(tail, fn(fa) :: revList)
810-
case Empty => fromListReverse(revList)
810+
case _ => fromListReverse(revList)
811811
}
812812
loop(fa, Nil)
813813
}
@@ -919,10 +919,10 @@ object TreeList extends TreeListInstances0 {
919919
either match {
920920
case Right(b) =>
921921
loop(rest :: tail, b :: acc)
922-
case Left(a) =>
923-
loop(fn(a) :: rest :: tail, acc)
922+
case Left(aa) =>
923+
loop(fn(aa) :: rest :: tail, acc)
924924
}
925-
case Empty =>
925+
case _ =>
926926
loop(tail, acc)
927927
}
928928
case Nil => acc

0 commit comments

Comments
 (0)