I have two Kotlin classes in the same package:
Foo.kt
:
data class Foo(
val map: Map<String, String>? = null
)
Bar.kt
:
class Bar {
init {
val foo = Foo()
if (filter.map != null) {
val value = filter.map["some_key"] // IDE shows successful smart cast here
}
}
}
Then trying to compile only one class Bar.kt
:
kotlinc Bar.kt -d output
Class Foo.kt
resides in the same package, but nevertheless I’m getting the following compiler error:
error: smart cast to 'Map<String, String>' is impossible, because '...' is a public API property declared in different module
However compiling both classes completes successfully:
kotlinc Bar.kt Foo.kt -d output // OK
So, my question: is it possible to compile only one Bar.kt
class without smart cast error?