diff --git a/coil-core/src/commonMain/kotlin/coil3/util/utils.kt b/coil-core/src/commonMain/kotlin/coil3/util/utils.kt index 096a60d10..df62f474b 100644 --- a/coil-core/src/commonMain/kotlin/coil3/util/utils.kt +++ b/coil-core/src/commonMain/kotlin/coil3/util/utils.kt @@ -123,12 +123,12 @@ object InternalCoilUtils { } fun resolveImmediateDispatcher(context: CoroutineContext): CoroutineContext { - var dispatcher: CoroutineContext? = context[CoroutineDispatcher] + var dispatcher = context[CoroutineDispatcher] if (dispatcher is MainCoroutineDispatcher) { try { - dispatcher = dispatcher.immediate + return dispatcher.immediate } catch (_: UnsupportedOperationException) {} } - return dispatcher ?: immediateDispatcher + return immediateDispatcher } }