Skip to content

Commit 3646036

Browse files
authored
Merge pull request scala/scala#10612 from som-snytt/lint/booleans
Lint unnamed boolean literal args [ci: last-only]
2 parents 22453d0 + a072237 commit 3646036

17 files changed

+95
-87
lines changed

library/src/scala/collection/Iterable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
429429
* which requires only a single traversal.
430430
*/
431431
def partition(p: A => Boolean): (C, C) = {
432-
val first = new View.Filter(this, p, false)
433-
val second = new View.Filter(this, p, true)
432+
val first = new View.Filter(this, p, isFlipped = false)
433+
val second = new View.Filter(this, p, isFlipped = true)
434434
(fromSpecific(first), fromSpecific(second))
435435
}
436436

library/src/scala/collection/MapView.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ trait MapView[K, +V]
5151
*/
5252
override def mapValues[W](f: V => W): MapView[K, W] = new MapView.MapValues(this, f)
5353

54-
override def filter(pred: ((K, V)) => Boolean): MapView[K, V] = new MapView.Filter(this, false, pred)
54+
override def filter(pred: ((K, V)) => Boolean): MapView[K, V] = new MapView.Filter(this, isFlipped = false, pred)
5555

56-
override def filterNot(pred: ((K, V)) => Boolean): MapView[K, V] = new MapView.Filter(this, true, pred)
56+
override def filterNot(pred: ((K, V)) => Boolean): MapView[K, V] = new MapView.Filter(this, isFlipped = true, pred)
5757

5858
override def partition(p: ((K, V)) => Boolean): (MapView[K, V], MapView[K, V]) = (filter(p), filterNot(p))
5959

library/src/scala/collection/StringParsers.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ private[scala] object StringParsers {
2828
private final val longOverflowBoundary = -922337203685477580L
2929
private final val longOverflowDigit = 9
3030

31+
private final val POS = true
32+
3133
@inline
3234
private[this] final def decValue(ch: Char): Int = java.lang.Character.digit(ch, 10)
3335

@@ -72,9 +74,9 @@ private[scala] object StringParsers {
7274
if (v > -1) Some(v.toByte)
7375
else None
7476
}
75-
else if (v > -1) stepToOverflow(from, len, -v, true, Byte.MinValue).map(_.toByte)
76-
else if (first == '+') stepToOverflow(from, len, 0, true, Byte.MinValue).map(_.toByte)
77-
else if (first == '-') stepToOverflow(from, len, 0, false, Byte.MinValue).map(_.toByte)
77+
else if (v > -1) stepToOverflow(from, len, -v, POS, Byte.MinValue).map(_.toByte)
78+
else if (first == '+') stepToOverflow(from, len, 0, POS, Byte.MinValue).map(_.toByte)
79+
else if (first == '-') stepToOverflow(from, len, 0, !POS, Byte.MinValue).map(_.toByte)
7880
else None
7981
}
8082
}
@@ -91,9 +93,9 @@ private[scala] object StringParsers {
9193
if (v > -1) Some(v.toShort)
9294
else None
9395
}
94-
else if (v > -1) stepToOverflow(from, len, -v, true, Short.MinValue).map(_.toShort)
95-
else if (first == '+') stepToOverflow(from, len, 0, true, Short.MinValue).map(_.toShort)
96-
else if (first == '-') stepToOverflow(from, len, 0, false, Short.MinValue).map(_.toShort)
96+
else if (v > -1) stepToOverflow(from, len, -v, POS, Short.MinValue).map(_.toShort)
97+
else if (first == '+') stepToOverflow(from, len, 0, POS, Short.MinValue).map(_.toShort)
98+
else if (first == '-') stepToOverflow(from, len, 0, !POS, Short.MinValue).map(_.toShort)
9799
else None
98100
}
99101
}
@@ -125,9 +127,9 @@ private[scala] object StringParsers {
125127
if (v > -1) Some(v)
126128
else None
127129
}
128-
else if (v > -1) step(1, -v, true)
129-
else if (first == '+') step(1, 0, true)
130-
else if (first == '-') step(1, 0, false)
130+
else if (v > -1) step(1, -v, POS)
131+
else if (first == '+') step(1, 0, POS)
132+
else if (first == '-') step(1, 0, !POS)
131133
else None
132134
}
133135
}
@@ -160,9 +162,9 @@ private[scala] object StringParsers {
160162
if (v > -1) Some(v)
161163
else None
162164
}
163-
else if (v > -1) step(1, -v, true)
164-
else if (first == '+') step(1, 0, true)
165-
else if (first == '-') step(1, 0, false)
165+
else if (v > -1) step(1, -v, POS)
166+
else if (first == '+') step(1, 0, POS)
167+
else if (first == '-') step(1, 0, !POS)
166168
else None
167169
}
168170
}

library/src/scala/collection/immutable/HashSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ private final class HashCollisionSetNode[A](val originalHash: Int, val hash: Int
18221822
}
18231823

18241824
override def diff(that: SetNode[A], shift: Int): SetNode[A] =
1825-
filterImpl(that.contains(_, originalHash, hash, shift), true)
1825+
filterImpl(that.contains(_, originalHash, hash, shift), flipped = true)
18261826

18271827
override def equals(that: Any): Boolean =
18281828
that match {

library/src/scala/collection/immutable/NumericRange.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ object NumericRange {
456456

457457
@SerialVersionUID(3L)
458458
class Inclusive[T](start: T, end: T, step: T)(implicit num: Integral[T])
459-
extends NumericRange(start, end, step, true) {
459+
extends NumericRange(start, end, step, isInclusive = true) {
460460
override def copy(start: T, end: T, step: T): Inclusive[T] =
461461
NumericRange.inclusive(start, end, step)
462462

@@ -465,7 +465,7 @@ object NumericRange {
465465

466466
@SerialVersionUID(3L)
467467
class Exclusive[T](start: T, end: T, step: T)(implicit num: Integral[T])
468-
extends NumericRange(start, end, step, false) {
468+
extends NumericRange(start, end, step, isInclusive = false) {
469469
override def copy(start: T, end: T, step: T): Exclusive[T] =
470470
NumericRange(start, end, step)
471471

library/src/scala/collection/mutable/AnyRefMap.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K => V, initi
4848
with Serializable {
4949

5050
import AnyRefMap._
51-
def this() = this(AnyRefMap.exceptionDefault, 16, true)
51+
def this() = this(AnyRefMap.exceptionDefault, 16, initBlank = true)
5252

5353
/** Creates a new `AnyRefMap` that returns default values according to a supplied key-value mapping. */
54-
def this(defaultEntry: K => V) = this(defaultEntry, 16, true)
54+
def this(defaultEntry: K => V) = this(defaultEntry, 16, initBlank = true)
5555

5656
/** Creates a new `AnyRefMap` with an initial buffer of specified size.
5757
*
5858
* An `AnyRefMap` can typically contain half as many elements as its buffer size
5959
* before it requires resizing.
6060
*/
61-
def this(initialBufferSize: Int) = this(AnyRefMap.exceptionDefault, initialBufferSize, true)
61+
def this(initialBufferSize: Int) = this(AnyRefMap.exceptionDefault, initialBufferSize, initBlank = true)
6262

6363
/** Creates a new `AnyRefMap` with specified default values and initial buffer size. */
64-
def this(defaultEntry: K => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, true)
64+
def this(defaultEntry: K => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, initBlank = true)
6565

6666
private[this] var mask = 0
6767
private[this] var _size = 0
@@ -387,7 +387,7 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K => V, initi
387387
val hz = java.util.Arrays.copyOf(_hashes, _hashes.length)
388388
val kz = java.util.Arrays.copyOf(_keys, _keys.length)
389389
val vz = java.util.Arrays.copyOf(_values, _values.length)
390-
val arm = new AnyRefMap[K, V](defaultEntry, 1, false)
390+
val arm = new AnyRefMap[K, V](defaultEntry, 1, initBlank = false)
391391
arm.initializeTo(mask, _size, _vacant, hz, kz, vz)
392392
arm
393393
}
@@ -436,7 +436,7 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K => V, initi
436436
* collection immediately.
437437
*/
438438
def mapValuesNow[V1](f: V => V1): AnyRefMap[K, V1] = {
439-
val arm = new AnyRefMap[K,V1](AnyRefMap.exceptionDefault, 1, false)
439+
val arm = new AnyRefMap[K,V1](AnyRefMap.exceptionDefault, 1, initBlank = false)
440440
val hz = java.util.Arrays.copyOf(_hashes, _hashes.length)
441441
val kz = java.util.Arrays.copyOf(_keys, _keys.length)
442442
val vz = new Array[AnyRef](_values.length)

library/src/scala/collection/mutable/CollisionProofHashMap.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double
112112
}
113113
}
114114

115-
override def update(key: K, value: V): Unit = put0(key, value, false)
115+
override def update(key: K, value: V): Unit = put0(key, value, getOld = false)
116116

117-
override def put(key: K, value: V): Option[V] = put0(key, value, true) match {
117+
override def put(key: K, value: V): Option[V] = put0(key, value, getOld = true) match {
118118
case null => None
119119
case sm => sm
120120
}
121121

122-
def addOne(elem: (K, V)): this.type = { put0(elem._1, elem._2, false); this }
122+
def addOne(elem: (K, V)): this.type = { put0(elem._1, elem._2, getOld = false); this }
123123

124124
@`inline` private[this] def put0(key: K, value: V, getOld: Boolean): Some[V] = {
125125
if(contentSize + 1 >= threshold) growTable(table.length * 2)
@@ -403,7 +403,7 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double
403403
if(contentSize + 1 >= threshold) growTable(table.length * 2)
404404
// Avoid recomputing index if the `defaultValue()` or new element hasn't triggered a table resize.
405405
val newIdx = if (table0 eq table) idx else index(hash)
406-
put0(key, default, false, hash, newIdx)
406+
put0(key, default, getOld = false, hash, newIdx)
407407
default
408408
}
409409

@@ -725,7 +725,7 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double
725725
case nn: LLNode @uc => (nn.key, nn.hash, nn.value)
726726
case nn: RBNode @uc => (nn.key, nn.hash, nn.value)
727727
}
728-
val n = new RBNode(key, hash, value, false, left, right, null)
728+
val n = new RBNode(key, hash, value, red = false, left, right, null)
729729
if(left ne null) left.parent = n
730730
right.parent = n
731731
n

library/src/scala/collection/mutable/HashMap.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
174174
growTable(table.length * 2)
175175
index(hash)
176176
} else indexedHash
177-
put0(key, value, false, hash, newIndexedHash)
177+
put0(key, value, getOld = false, hash, newIndexedHash)
178178

179179
case (Some(_), Some(newValue)) => foundNode.value = newValue
180180
}
@@ -470,13 +470,13 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
470470
if(contentSize + 1 >= threshold) growTable(table.length * 2)
471471
// Avoid recomputing index if the `defaultValue()` or new element hasn't triggered a table resize.
472472
val newIdx = if (table0 eq table) idx else index(hash)
473-
put0(key, default, false, hash, newIdx)
473+
put0(key, default, getOld = false, hash, newIdx)
474474
default
475475
}
476476
}
477477
}
478478

479-
override def put(key: K, value: V): Option[V] = put0(key, value, true) match {
479+
override def put(key: K, value: V): Option[V] = put0(key, value, getOld = true) match {
480480
case null => None
481481
case sm => sm
482482
}
@@ -486,9 +486,9 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
486486
case nd => Some(nd.value)
487487
}
488488

489-
override def update(key: K, value: V): Unit = put0(key, value, false)
489+
override def update(key: K, value: V): Unit = put0(key, value, getOld = false)
490490

491-
def addOne(elem: (K, V)): this.type = { put0(elem._1, elem._2, false); this }
491+
def addOne(elem: (K, V)): this.type = { put0(elem._1, elem._2, getOld = false); this }
492492

493493
def subtractOne(elem: K): this.type = { remove0(elem); this }
494494

library/src/scala/collection/mutable/LinkedHashMap.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ class LinkedHashMap[K, V]
103103
super.contains(key) // A subclass might override `get`, use the default implementation `contains`.
104104
}
105105

106-
override def put(key: K, value: V): Option[V] = put0(key, value, true) match {
106+
override def put(key: K, value: V): Option[V] = put0(key, value, getOld = true) match {
107107
case null => None
108108
case sm => sm
109109
}
110110

111-
override def update(key: K, value: V): Unit = put0(key, value, false)
111+
override def update(key: K, value: V): Unit = put0(key, value, getOld = false)
112112

113113
override def remove(key: K): Option[V] = removeEntry0(key) match {
114114
case null => None
@@ -144,7 +144,7 @@ class LinkedHashMap[K, V]
144144
if (contentSize + 1 >= threshold) growTable(table.length * 2)
145145
// Avoid recomputing index if the `defaultValue()` or new element hasn't triggered a table resize.
146146
val newIdx = if (table0 eq table) idx else index(hash)
147-
put0(key, default, false, hash, newIdx)
147+
put0(key, default, getOld = false, hash, newIdx)
148148
default
149149
}
150150
}
@@ -299,7 +299,7 @@ class LinkedHashMap[K, V]
299299
growTable(table.length * 2)
300300
index(hash)
301301
} else indexedHash
302-
put0(key, value, false, hash, newIndexedHash)
302+
put0(key, value, getOld = false, hash, newIndexedHash)
303303

304304
case (Some(_), Some(newValue)) => foundEntry.value = newValue
305305
}

library/src/scala/collection/mutable/LongMap.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class LongMap[V] private[collection] (defaultEntry: Long => V, initialBuff
4343
with Serializable {
4444
import LongMap._
4545

46-
def this() = this(LongMap.exceptionDefault, 16, true)
46+
def this() = this(LongMap.exceptionDefault, 16, initBlank = true)
4747

4848
// TODO: override clear() with an optimization more tailored for efficiency.
4949
override protected def fromSpecific(coll: scala.collection.IterableOnce[(Long, V)]): LongMap[V] = {
@@ -56,17 +56,17 @@ final class LongMap[V] private[collection] (defaultEntry: Long => V, initialBuff
5656
override protected def newSpecificBuilder: Builder[(Long, V),LongMap[V]] = new GrowableBuilder(LongMap.empty[V])
5757

5858
/** Creates a new `LongMap` that returns default values according to a supplied key-value mapping. */
59-
def this(defaultEntry: Long => V) = this(defaultEntry, 16, true)
59+
def this(defaultEntry: Long => V) = this(defaultEntry, 16, initBlank = true)
6060

6161
/** Creates a new `LongMap` with an initial buffer of specified size.
6262
*
6363
* A LongMap can typically contain half as many elements as its buffer size
6464
* before it requires resizing.
6565
*/
66-
def this(initialBufferSize: Int) = this(LongMap.exceptionDefault, initialBufferSize, true)
66+
def this(initialBufferSize: Int) = this(LongMap.exceptionDefault, initialBufferSize, initBlank = true)
6767

6868
/** Creates a new `LongMap` with specified default values and initial buffer size. */
69-
def this(defaultEntry: Long => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, true)
69+
def this(defaultEntry: Long => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, initBlank = true)
7070

7171
private[this] var mask = 0
7272
private[this] var extraKeys: Int = 0
@@ -455,7 +455,7 @@ final class LongMap[V] private[collection] (defaultEntry: Long => V, initialBuff
455455
override def clone(): LongMap[V] = {
456456
val kz = java.util.Arrays.copyOf(_keys, _keys.length)
457457
val vz = java.util.Arrays.copyOf(_values, _values.length)
458-
val lm = new LongMap[V](defaultEntry, 1, false)
458+
val lm = new LongMap[V](defaultEntry, 1, initBlank = false)
459459
lm.initializeTo(mask, extraKeys, zeroValue, minValue, _size, _vacant, kz, vz)
460460
lm
461461
}
@@ -522,7 +522,7 @@ final class LongMap[V] private[collection] (defaultEntry: Long => V, initialBuff
522522
def mapValuesNow[V1](f: V => V1): LongMap[V1] = {
523523
val zv = if ((extraKeys & 1) == 1) f(zeroValue.asInstanceOf[V]).asInstanceOf[AnyRef] else null
524524
val mv = if ((extraKeys & 2) == 2) f(minValue.asInstanceOf[V]).asInstanceOf[AnyRef] else null
525-
val lm = new LongMap[V1](LongMap.exceptionDefault, 1, false)
525+
val lm = new LongMap[V1](LongMap.exceptionDefault, 1, initBlank = false)
526526
val kz = java.util.Arrays.copyOf(_keys, _keys.length)
527527
val vz = new Array[AnyRef](_values.length)
528528
var i,j = 0

0 commit comments

Comments
 (0)