Skip to content

Commit

Permalink
Merge pull request #764 from arkivanov/kotlin-1.9.20
Browse files Browse the repository at this point in the history
Updated Kotlin to 1.9.20
  • Loading branch information
CherryPerry committed Nov 3, 2023
2 parents a0ea723 + 5bc371f commit 2d8a1b3
Show file tree
Hide file tree
Showing 39 changed files with 98 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.badoo.reaktive.test.observable.onNext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
Expand All @@ -20,13 +19,14 @@ import kotlin.test.assertTrue
class ObservableAsFlowTest {

private val upstream = TestObservable<Int?>()
private val scope = CoroutineScope(Dispatchers.Unconfined)

@Test
fun produces_values_in_correct_order_WHEN_upstream_produced_values() {
val values = listOf(0, null, 1, null, 2)
val list = ArrayList<Int?>()

GlobalScope.launch(Dispatchers.Unconfined) {
scope.launch(Dispatchers.Unconfined) {
upstream.asFlow().collect {
list.add(it)
}
Expand All @@ -40,7 +40,7 @@ class ObservableAsFlowTest {
@Test
fun completes_WHEN_upstream_completed() {
var isCompleted = false
GlobalScope.launch(Dispatchers.Unconfined) {
scope.launch {
upstream.asFlow().collect {}
isCompleted = true
}
Expand All @@ -54,7 +54,7 @@ class ObservableAsFlowTest {
fun produces_error_WHEN_upstream_produced_error() {
var isError = false

GlobalScope.launch(Dispatchers.Unconfined) {
scope.launch {
try {
upstream.asFlow().collect {}
} catch (e: Throwable) {
Expand All @@ -71,7 +71,7 @@ class ObservableAsFlowTest {
fun unsubscribes_from_upstream_WHEN_flow_is_cancelled() {
val scope = CoroutineScope(Dispatchers.Unconfined)

scope.launch(Dispatchers.Unconfined) {
scope.launch {
upstream.asFlow().collect {}
}

Expand All @@ -84,7 +84,7 @@ class ObservableAsFlowTest {
fun throws_exception_WHEN_upstream_subscribe_throws_exception() {
var isThrown = false

GlobalScope.launch(Dispatchers.Unconfined) {
scope.launch {
observableUnsafe<Nothing> { throw Exception() }
.asFlow()
.run {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ android.useAndroidX=true
android.enableJetifier=true

kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.applyDefaultHierarchyTemplate=false

# For compatibility with Kotlin 1.9.0, see https://github.com/badoo/Reaktive/issues/697
android.experimental.lint.version=8.1.0
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "1.9.10"
kotlin = "1.9.20"
kotlinx-coroutines = "1.7.3"
detekt = "1.22.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class DarwinPlugin : Plugin<Project> {
iosSimulatorArm64().disableIfUndefined(Target.IOS)
watchosArm32().disableIfUndefined(Target.WATCHOS)
watchosArm64().disableIfUndefined(Target.WATCHOS)
watchosX86().disableIfUndefined(Target.WATCHOS)
watchosX64().disableIfUndefined(Target.WATCHOS)
watchosSimulatorArm64().disableIfUndefined(Target.WATCHOS)
tvosArm64().disableIfUndefined(Target.TVOS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class MppConfigurationPlugin : Plugin<Project> {
implementation(target.getLibrary("kotlin-test-annotations"))
}
}

targets.configureEach {
compilations.configureEach {
compilerOptions.configure {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}
}
}

Expand Down Expand Up @@ -96,9 +104,6 @@ class MppConfigurationPlugin : Plugin<Project> {
maybeCreate("watchosArm64Main").dependsOn(getByName("darwinCommonMain"))
maybeCreate("watchosArm64Test").dependsOn(getByName("darwinCommonTest"))

maybeCreate("watchosX86Main").dependsOn(getByName("darwinCommonMain"))
maybeCreate("watchosX86Test").dependsOn(getByName("darwinCommonTest"))

maybeCreate("watchosX64Main").dependsOn(getByName("darwinCommonMain"))
maybeCreate("watchosX64Test").dependsOn(getByName("darwinCommonTest"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class PublishConfigurationPlugin : Plugin<Project> {
"iosSimulatorArm64" to Target.shouldPublishTarget(project, Target.IOS),
"watchosArm32" to Target.shouldPublishTarget(project, Target.WATCHOS),
"watchosArm64" to Target.shouldPublishTarget(project, Target.WATCHOS),
"watchosX86" to Target.shouldPublishTarget(project, Target.WATCHOS),
"watchosX64" to Target.shouldPublishTarget(project, Target.WATCHOS),
"watchosSimulatorArm64" to Target.shouldPublishTarget(project, Target.WATCHOS),
"tvosArm64" to Target.shouldPublishTarget(project, Target.TVOS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.badoo.reaktive.completable

import com.badoo.reaktive.disposable.Disposable
import com.badoo.reaktive.plugin.onAssembleCompletable
import kotlin.native.concurrent.SharedImmutable

/**
* ⚠️ Advanced use only: creates an instance of [Completable] without any safeguards by calling `onSubscribe` with a [CompletableObserver].
Expand Down Expand Up @@ -38,7 +37,6 @@ fun completableOfError(error: Throwable): Completable =
*/
fun Throwable.toCompletableOfError(): Completable = completableOfError(this)

@SharedImmutable
private val completableOfEmpty by lazy {
completableUnsafe { observer ->
val disposable = Disposable()
Expand All @@ -57,7 +55,6 @@ private val completableOfEmpty by lazy {
*/
fun completableOfEmpty(): Completable = completableOfEmpty

@SharedImmutable
private val completableOfNever by lazy {
completableUnsafe { observer ->
observer.onSubscribe(Disposable())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.badoo.reaktive.maybe

import com.badoo.reaktive.disposable.Disposable
import com.badoo.reaktive.plugin.onAssembleMaybe
import kotlin.native.concurrent.SharedImmutable

/**
* ⚠️ Advanced use only: creates an instance of [Maybe] without any safeguards by calling `onSubscribe` with a [MaybeObserver].
Expand Down Expand Up @@ -80,7 +79,6 @@ fun <T> maybeOfError(error: Throwable): Maybe<T> =
*/
fun <T> Throwable.toMaybeOfError(): Maybe<T> = maybeOfError(this)

@SharedImmutable
private val maybeOfEmpty by lazy {
maybeUnsafe<Nothing> { observer ->
val disposable = Disposable()
Expand All @@ -99,7 +97,6 @@ private val maybeOfEmpty by lazy {
*/
fun <T> maybeOfEmpty(): Maybe<T> = maybeOfEmpty

@SharedImmutable
private val maybeOfNever by lazy {
maybeUnsafe<Nothing> { observer ->
observer.onSubscribe(Disposable())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.badoo.reaktive.observable

import com.badoo.reaktive.disposable.Disposable
import com.badoo.reaktive.plugin.onAssembleObservable
import kotlin.native.concurrent.SharedImmutable

/**
* ⚠️ Advanced use only: creates an instance of [Observable] without any safeguards by calling `onSubscribe` with an [ObservableObserver].
Expand Down Expand Up @@ -105,7 +104,6 @@ fun <T> observableOfError(error: Throwable): Observable<T> =
*/
fun <T> Throwable.toObservableOfError(): Observable<T> = observableOfError(this)

@SharedImmutable
private val observableOfEmpty by lazy {
observableUnsafe<Nothing> { observer ->
val disposable = Disposable()
Expand All @@ -124,7 +122,6 @@ private val observableOfEmpty by lazy {
*/
fun <T> observableOfEmpty(): Observable<T> = observableOfEmpty

@SharedImmutable
private val observableOfNever by lazy {
observableUnsafe<Nothing> { observer ->
observer.onSubscribe(Disposable())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.badoo.reaktive.scheduler

import com.badoo.reaktive.utils.atomic.AtomicReference
import kotlin.native.concurrent.SharedImmutable

/**
* Provides the global instance of Main [Scheduler]
Expand Down Expand Up @@ -33,27 +32,21 @@ val singleScheduler: Scheduler get() = singleSchedulerFactory.value.value
*/
val newThreadScheduler: Scheduler get() = newThreadSchedulerFactory.value.value

@SharedImmutable
private val mainSchedulerFactory: AtomicReference<Lazy<Scheduler>> =
AtomicReference(lazy(::createMainScheduler))

@SharedImmutable
private val computationSchedulerFactory: AtomicReference<Lazy<Scheduler>> =
AtomicReference(lazy(::createComputationScheduler))

@SharedImmutable
private val ioSchedulerFactory: AtomicReference<Lazy<Scheduler>> =
AtomicReference(lazy(::createIoScheduler))

@SharedImmutable
private val trampolineSchedulerFactory: AtomicReference<Lazy<Scheduler>> =
AtomicReference(lazy(::createTrampolineScheduler))

@SharedImmutable
private val singleSchedulerFactory: AtomicReference<Lazy<Scheduler>> =
AtomicReference(lazy(::createSingleScheduler))

@SharedImmutable
private val newThreadSchedulerFactory: AtomicReference<Lazy<Scheduler>> =
AtomicReference(lazy(::createNewThreadScheduler))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.badoo.reaktive.single

import com.badoo.reaktive.disposable.Disposable
import com.badoo.reaktive.plugin.onAssembleSingle
import kotlin.native.concurrent.SharedImmutable

/**
* ⚠️ Advanced use only: creates an instance of [Single] without any safeguards by calling `onSubscribe` with a [SingleObserver].
Expand Down Expand Up @@ -38,7 +37,6 @@ fun <T> singleOf(value: T): Single<T> =
*/
fun <T> T.toSingle(): Single<T> = singleOf(this)

@SharedImmutable
private val singleOfNever by lazy {
singleUnsafe<Nothing> { observer ->
observer.onSubscribe(Disposable())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.badoo.reaktive.utils

import com.badoo.reaktive.utils.atomic.AtomicReference
import kotlin.native.concurrent.SharedImmutable

@SharedImmutable
@Suppress("ObjectPropertyName")
private val _reaktiveUncaughtErrorHandler: AtomicReference<(Throwable) -> Unit> =
AtomicReference(createDefaultUncaughtErrorHandler())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class CompletableToCompletableTestsImpl(
transform: Completable.() -> Completable
) : CompletableToCompletableTests, SourceTests by SourceTestsImpl(TestCompletable(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestCompletable()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class CompletableToMaybeTestsImpl(
transform: Completable.() -> Maybe<*>
) : CompletableToMaybeTests, SourceTests by SourceTestsImpl(TestCompletable(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestCompletable()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class CompletableToObservableTestsImpl(
transform: Completable.() -> Observable<*>
) : CompletableToObservableTests, SourceTests by SourceTestsImpl(TestCompletable(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestCompletable()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class CompletableToSingleTestsImpl(
transform: Completable.() -> Single<*>
) : CompletableToSingleTests, SourceTests by SourceTestsImpl(TestCompletable(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestCompletable()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class MaybeToCompletableTestsImpl(
transform: Maybe<Unit>.() -> Completable
) : MaybeToCompletableTests, SourceTests by SourceTestsImpl(TestMaybe<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestMaybe<Unit>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class MaybeToMaybeTestsImpl(
transform: Maybe<Unit>.() -> Maybe<*>
) : MaybeToMaybeTests, SourceTests by SourceTestsImpl(TestMaybe<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestMaybe<Unit>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class MaybeToObservableTestsImpl(
transform: Maybe<Unit>.() -> Observable<*>
) : MaybeToObservableTests, SourceTests by SourceTestsImpl(TestMaybe<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestMaybe<Unit>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class MaybeToSingleTestsImpl(
transform: Maybe<Unit>.() -> Single<*>
) : MaybeToSingleTests, SourceTests by SourceTestsImpl(TestMaybe<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestMaybe<Unit>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AutoConnectTest {

@Test
fun does_not_connect_second_time_WHEN_subscriberCount_is_1_and_subscribed_second_time() {
var isConnected = false
var isConnected: Boolean
val upstream = testUpstream(connect = { isConnected = true })
val autoConnect = upstream.autoConnect(subscriberCount = 1)
autoConnect.test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class ObservableToCompletableTestsImpl(
transform: Observable<*>.() -> Completable
) : ObservableToCompletableTests, SourceTests by SourceTestsImpl(TestObservable<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestObservable<Nothing>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class ObservableToMaybeTestsImpl(
transform: Observable<*>.() -> Maybe<*>
) : ObservableToMaybeTests, SourceTests by SourceTestsImpl(TestObservable<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestObservable<Nothing>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class ObservableToObservableTestsImpl(
transform: Observable<*>.() -> Observable<*>
) : ObservableToObservableTests, SourceTests by SourceTestsImpl(TestObservable<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestObservable<Nothing>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class ObservableToSingleTestsImpl(
transform: Observable<*>.() -> Single<*>
) : ObservableToSingleTests, SourceTests by SourceTestsImpl(TestObservable<Nothing>(), { transform().test() }) {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestObservable<Nothing>()
private val observer = upstream.transform().test()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class PublishGenericTestsImpl(
transform: Observable<Int?>.() -> ConnectableObservable<Int?>
) : PublishGenericTests {

// See: https://youtrack.jetbrains.com/issue/KT-63132
constructor() : this(transform = { error("Dummy") })

private val upstream = TestObservable<Int?>()
private val publish = upstream.transform()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RefCountTest {

@Test
fun does_not_connect_second_time_WHEN_subscriberCount_is_1_and_subscribed_second_time() {
var isConnected = false
var isConnected: Boolean
val upstream = testUpstream(connect = { isConnected = true })
val refCount = upstream.refCount(subscriberCount = 1)
refCount.test()
Expand Down
Loading

0 comments on commit 2d8a1b3

Please sign in to comment.