Skip to content

Commit 9b2bd3a

Browse files
dkhalanskyjbqwwdfsad
authored andcommitted
Work around KT-63238 by removing Any.unwrap altogether
1 parent 2ec8c28 commit 9b2bd3a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kotlinx-coroutines-core/concurrent/src/internal/LockFreeLinkedList.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public actual open class LockFreeLinkedListNode {
8585
}
8686

8787
// LINEARIZABLE. Returns next non-removed Node
88-
public actual val nextNode: Node get() = next.unwrap()
88+
public actual val nextNode: Node get() =
89+
next.let { (it as? Removed)?.ref ?: it as Node } // unwraps the `next` node
8990

9091
// LINEARIZABLE WHEN THIS NODE IS NOT REMOVED:
9192
// Returns prev non-removed Node, makes sure prev is correct (prev.next === this)
@@ -323,9 +324,6 @@ private class Removed(@JvmField val ref: Node) {
323324
override fun toString(): String = "Removed[$ref]"
324325
}
325326

326-
@PublishedApi
327-
internal fun Any.unwrap(): Node = (this as? Removed)?.ref ?: this as Node
328-
329327
/**
330328
* Head (sentinel) item of the linked list that is never removed.
331329
*

0 commit comments

Comments
 (0)