Skip to content

K/N Dispatchers.IO import conflicts #4568

@matejdro

Description

@matejdro

Describe the bug

It seems there is an import conflict regarding Dispatchers.IO on the K/N vs JVM.

Following code compiles on the JVM:

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

suspend fun test() {
    withContext(Dispatchers.IO) {
        
    }
}

But it fails on the K/N:

Cannot access 'val IO: CoroutineDispatcher': it is internal in 'kotlinx.coroutines.Dispatchers'.

the solution is to add the import manually:

import kotlinx.coroutines.IO

however, when performing "Optimize imports" actions in the KMP common code, IntelliJ will remove that import, causing the K/N builds to fail afterwards, without IDE showing anything red.

This makes it difficult to work in the common code with automatic import optimizations enabled as IntelliJ will keep removing this.

Is this a bug in the IntelliJ or the coroutines library?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions