The following causes smartcast to work for me:
fun hasEmptyValue(column: Pair<String, Any>): Boolean {
val second = column.second
return when (second) {
is Option<*> -> second.isEmpty() //Smart cast to arrow.core.Option<*>
else -> false
}
}
The explanation for why a smart cast across modules is not allowed is on the Jetbrains issue tracker here:
A smart cast is only valid when multiple accesses of the same property are guaranteed to return the same value. If the property being accessed is defined in a different module from the access location, the module containing the property can be recompiled separately from the module where it’s accessed, breaking the key requirement of the smart cast. Therefore, cross-module smart casts are not allowed.