Skip to content

Commit 2a854a1

Browse files
committed
Address some review comments
1 parent 26e12c3 commit 2a854a1

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ private[collection] object RedBlackTree {
424424
}
425425

426426
private[this] def upd[A, B, B1 >: B](tree: Tree[A, B] | Null, k: A, v: B1, overwrite: Boolean)(implicit ordering: Ordering[A]): Tree[A, B1] = if (tree eq null) {
427-
RedTree(k, v, null: Tree[A, B1] | Null, null: Tree[A, B1] | Null)
427+
RedTree[A, B1](k, v, null, null)
428428
} else if (k.asInstanceOf[AnyRef] eq tree.key.asInstanceOf[AnyRef]) {
429429
if (overwrite)
430430
tree.withV(v)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K -> V, initi
202202
*/
203203
def getOrNull(key: K): V | Null = {
204204
val i = seekEntry(hashOf(key), key)
205-
if (i < 0) null else _values(i).asInstanceOf[V]
205+
if (i < 0) null else _values(i).asInstanceOf[V | Null]
206206
}
207207

208208
/** Retrieves the value associated with a key.

library/src/scala/collection/mutable/ListBuffer.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class ListBuffer[A]
189189
last0 = null
190190
}
191191

192-
private def locate(i: Int): Predecessor[A] | Null =
192+
private def locate(i: Int): Predecessor[A] =
193193
if (i == 0) null
194194
else if (i == len) last0
195195
else {
@@ -202,7 +202,7 @@ class ListBuffer[A]
202202
p.asInstanceOf[Predecessor[A]]
203203
}
204204

205-
private def getNext(p: Predecessor[A] | Null): List[A] =
205+
private def getNext(p: Predecessor[A]): List[A] =
206206
if (p == null) first else p.next
207207

208208
def update(idx: Int, elem: A): Unit = {
@@ -243,7 +243,7 @@ class ListBuffer[A]
243243
}
244244

245245
// `fresh` must be a `ListBuffer` that only we have access to
246-
private def insertAfter(prev: Predecessor[A] | Null, fresh: ListBuffer[A]): Unit = {
246+
private def insertAfter(prev: Predecessor[A], fresh: ListBuffer[A]): Unit = {
247247
if (!fresh.isEmpty) {
248248
val follow = getNext(prev)
249249
if (prev eq null) first = fresh.first else prev.next = fresh.first
@@ -291,7 +291,7 @@ class ListBuffer[A]
291291
throw new IllegalArgumentException("removing negative number of elements: " + count)
292292
}
293293

294-
private def removeAfter(prev: Predecessor[A] | Null, n: Int) = {
294+
private def removeAfter(prev: Predecessor[A], n: Int) = {
295295
@tailrec def ahead(p: List[A], n: Int): List[A] =
296296
if (n == 0) p else ahead(p.tail, n - 1)
297297
val nx = ahead(getNext(prev), n)
@@ -348,7 +348,7 @@ class ListBuffer[A]
348348
*/
349349
def filterInPlace(p: A => Boolean): this.type = {
350350
ensureUnaliased()
351-
var prev: Predecessor[A] | Null = null
351+
var prev: Predecessor[A] = null
352352
var cur: List[A] = first
353353
while (!cur.isEmpty) {
354354
val follow = cur.tail

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ final class LongMap[V] private[collection] (defaultEntry: Long -> V, initialBuff
230230
}
231231
else {
232232
val i = seekEntry(key)
233-
if (i < 0) null else _values(i).asInstanceOf[V]
233+
if (i < 0) null else _values(i).asInstanceOf[V | Null]
234234
}
235235
}
236236

library/src/scala/util/Properties.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ private[scala] trait PropertiesTrait {
5454

5555
def propIsSet(name: String) = System.getProperty(name) != null
5656
def propIsSetTo(name: String, value: String) = propOrNull(name) == value
57-
def propOrElse(name: String, alt: => String | Null) = Option(System.getProperty(name)).getOrElse(alt)
57+
def propOrNone(name: String): Option[String] = Option[String](System.getProperty(name))
58+
def propOrElse(name: String, alt: => String) = propOrNone(name).getOrElse(alt)
5859
def propOrEmpty(name: String) = propOrElse(name, "")
59-
def propOrNull(name: String): String | Null = propOrElse(name, null)
60-
def propOrNone(name: String) = Option(propOrNull(name))
60+
def propOrNull(name: String): String | Null = propOrNone(name).orNull
6161
def propOrFalse(name: String) = propOrNone(name) exists (x => List("yes", "on", "true") contains x.nn.toLowerCase)
6262
def setProp(name: String, value: String) = System.setProperty(name, value)
6363
def clearProp(name: String) = System.clearProperty(name)

library/src/scala/util/Using.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ object Using {
177177
import Manager._
178178

179179
private var closed = false
180-
@annotation.stableNull
181-
private[this] var resources: List[Resource[_]] | Null = Nil
180+
private[this] var resources: List[Resource[_]] = Nil
182181

183182
/** Registers the specified resource with this manager, so that
184183
* the resource is released when the manager is closed, and then
@@ -195,7 +194,7 @@ object Using {
195194
def acquire[R: Releasable](resource: R): Unit = {
196195
if (resource == null) throw new NullPointerException("null resource")
197196
if (closed) throw new IllegalStateException("Manager has already been closed")
198-
resources = new Resource(resource) :: resources.nn
197+
resources = new Resource(resource) :: resources
199198
}
200199

201200
private def manage[A](op: Manager => A): A = {
@@ -209,7 +208,7 @@ object Using {
209208
} finally {
210209
closed = true
211210
var rs = resources
212-
resources = null // allow GC, in case something is holding a reference to `this`
211+
resources = null.asInstanceOf[List[Resource[_]]] // allow GC, in case something is holding a reference to `this`
213212
while (rs != null && rs.nonEmpty) {
214213
val resource = rs.head
215214
rs = rs.tail

0 commit comments

Comments
 (0)