14
votes

I have a problem understanding the internal access modifier. In my examples I could not produce any situation where it behaves different then public. Even if I create a jars I can access the internal functions in the jar from outside the jar (from a different package unrelated to the one used in the jar). In the documentation the term module is used but I could not find out what a module is exactly.

My questions thus are:

  1. what is a module in kotlin?

  2. how does the access modifier internal differs from the public modiefier?

1

1 Answers

6
votes

The Kotlin compiler version M8 (0.8.11) ignores modules, more precisely, it works as if all your code were put into the same module, this is why you can't get a visibility error for internal.

Starting with the next milestone release, every IDE module you create has its own visibility scope, and when you try to access an internal declaration from one module in another, you get an error. Publics, on the other hand, are visible across the whole project.

UPDATE: This has not been turned on in M8, postponed for later

UPDATE: This has been turned on since later Kotlin milestones and betas