Kotlin fails to find extension functions and type aliases

I run into this frequently. Usually, changing an import fixes it for me until today.

Example problem:

package test1
enum class Foo {
  ONE
  TWO
}

package test2
import test1.Foo
fun main() {
  // Code references "Foo.ONE"
 // That works
}

package test2
import test1.Foo
import test1.Foo.ONE

fun main() {
  // Code references "ONE"
 // That fails
}

When this happens, I’m usually updating existing code. When the bug occurs, all extension function references and type aliases suddenly become “Unresolved reference” errors across the entire codebase. Usually, I will just remove a change like “import Foo.ONE” and instead reference “Foo.ONE” in the code and it will compile again.

Any idea on how I can debug this?

I found a way to workaround this by using more wildcard imports across the entire codebase. Submitted https://youtrack.jetbrains.com/issue/KT-38357