Skip to content

Commit

Permalink
Remove workarounds for obsolete compiler bugs (#2829)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad committed Sep 3, 2021
1 parent 61acb95 commit 3f459d5
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 16 deletions.
Expand Up @@ -43,7 +43,7 @@ public expect open class LockFreeLinkedListNode() {
public expect open class LockFreeLinkedListHead() : LockFreeLinkedListNode {
public val isEmpty: Boolean
public inline fun <reified T : LockFreeLinkedListNode> forEach(block: (T) -> Unit)
public final override fun remove(): Boolean // Actual return type is Nothing, KT-27534
public final override fun remove(): Nothing
}

/** @suppress **This is unstable API and it is subject to change.** */
Expand Down
Expand Up @@ -48,10 +48,9 @@ class DropTest : TestBase() {
expectUnreached()
}
}.drop(1)
.map {
.map<Int, Int> {
expect(4)
throw TestException()
42
}.catch { emit(42) }

expect(1)
Expand Down
Expand Up @@ -38,7 +38,6 @@ class FilterTest : TestBase() {
}.filter {
latch.receive()
throw TestException()
true
}.catch { emit(42) }

assertEquals(42, flow.single())
Expand Down Expand Up @@ -74,7 +73,6 @@ class FilterTest : TestBase() {
}.filterNot {
latch.receive()
throw TestException()
true
}.catch { emit(42) }

assertEquals(42, flow.single())
Expand Down
Expand Up @@ -72,7 +72,7 @@ abstract class FlatMapMergeBaseTest : FlatMapBaseTest() {
emit(2)
expectUnreached()
}.flatMap {
if (it == 1) flow<Int> {
if (it == 1) flow {
expect(5)
latch.send(Unit)
hang { expect(7) }
Expand Down
Expand Up @@ -83,7 +83,7 @@ class FlowOnTest : TestBase() {
}.map {
expect(2)
assertEquals("throwing", it)
throw TestException(); it
throw TestException()
}.flowOn(NamedDispatchers("throwing"))

assertFailsWith<TestException>(flow)
Expand Down
Expand Up @@ -39,10 +39,9 @@ class MapNotNullTest : TestBase() {
}
emit(1)
}
}.mapNotNull {
}.mapNotNull<Int, Int> {
latch.receive()
throw TestException()
it + 1
}.catch { emit(42) }

assertEquals(42, flow.single())
Expand Down
Expand Up @@ -250,7 +250,6 @@ class SampleTest : TestBase() {
expect(2)
yield()
throw TestException()
it
}

assertFailsWith<TestException>(flow)
Expand Down
Expand Up @@ -88,9 +88,8 @@ class TakeTest : TestBase() {
emit(1)
}
}.take(2)
.map {
.map<Int, Int> {
throw TestException()
42
}.catch { emit(42) }

assertEquals(42, flow.single())
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/js/src/internal/LinkedList.kt
Expand Up @@ -177,5 +177,5 @@ public open class LinkedListHead : LinkedListNode() {
}

// just a defensive programming -- makes sure that list head sentinel is never removed
public final override fun remove(): Boolean = throw UnsupportedOperationException()
public final override fun remove(): Nothing = throw UnsupportedOperationException()
}
Expand Up @@ -646,7 +646,7 @@ public actual open class LockFreeLinkedListHead : LockFreeLinkedListNode() {
}

// just a defensive programming -- makes sure that list head sentinel is never removed
public actual final override fun remove(): Boolean = error("head cannot be removed")
public actual final override fun remove(): Nothing = error("head cannot be removed")

// optimization: because head is never removed, we don't have to read _next.value to check these:
override val isRemoved: Boolean get() = false
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/native/src/internal/LinkedList.kt
Expand Up @@ -166,5 +166,5 @@ public open class LinkedListHead : LinkedListNode() {
}

// just a defensive programming -- makes sure that list head sentinel is never removed
public final override fun remove(): Boolean = throw UnsupportedOperationException()
public final override fun remove(): Nothing = throw UnsupportedOperationException()
}
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/native/test/TestBase.kt
Expand Up @@ -78,7 +78,7 @@ public actual open class TestBase actual constructor() {
var exCount = 0
var ex: Throwable? = null
try {
runBlocking(block = block, context = CoroutineExceptionHandler { context, e ->
runBlocking(block = block, context = CoroutineExceptionHandler { _, e ->
if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
exCount++
when {
Expand Down

0 comments on commit 3f459d5

Please sign in to comment.