Wrote a small kotlin app a few months ago and am now writing something larger together with other developers. Having a lot of difficulty with the visibility rules, ensuring proper encapsulation of internal classes, functions, and vals while at the same time allowing unit testing. The fact that packages are unrelated to visibility throws me off.
The technique we currently use is to add the internal modifier to all implementation details, leaving the public API with no modifier (which makes it public). The problem with this is that internals are visible to all the other code in the module, breaking encapsulation (and leading to bugs).
Maybe I'm missing something here, and am wondering what techniques people use with largish codebases.