Best way to handle multiple modules

What would be the best way to use multiple modules with Kotlin? More specifically, situation where data classes created in other module are accessed with different modules?

In this case smart cast fails and I have to add ugly !! modifier everywhere. Is there a way to tell Kotlin compiler to force enable smart cast? All modules are owned by me and always recompiled together, so that kind of security is unnecessary in my case.

For this particular problem, if you use the modules together, make sure you mark the type/property as final (in inheritance cases use sealed classes). Alternatively you may want to store the value locally and compare that, but perhaps your modules are not quite independent modules.

Yes, properties are all marked as val. But kotlin still does not smart casts that.

They need to be final at least, but it could be that smart cast actually wants to check that the property doesn’t change (val doesn’t mean that the return value does not change, it only means that there is no direct setter for the property).