Alexei Artsimovich
11/27/2023, 11:38 AMinternal
keyword plays a role in this. Should classes and methods that are not intended to be used outside a module be marked with the internal visibility so that changes to their signature do not cause dependent modules to be recompiled?Javier
11/27/2023, 11:46 AMephemient
11/27/2023, 11:48 AMinternal
is also effectively public
to any Java code, as well as public inline
usages of @PublishedApi internal
, so it does form part of the ABIEvgenii Mazhukin
11/27/2023, 1:31 PMinternal
same way as public
. As @Javier and @ephemient pointed out, there are ways to call other module's internal API.
However, part of the compileKotlin task's job is to calculate which files should be recompiled. If it is an incremental build, and dependent module doesn't use the changed APIs, for JVM we would not actually recompile any files in that module.
We're interested in improving compilation avoidance in that area, but there are no specific plans yet. Please vote on the issue if you feel that it strongly affects your projects: https://youtrack.jetbrains.com/issue/KT-63830/Compilation-avoidance-should-ignore-internal-changes-if-possible
To summarize: no avoidance. Nonetheless, it's a good idea to mark an API internal
, if it's intended to be internal. It would help your collaborators use proper APIs in their code. And, well, code is for people, compiler just makes it work.