Package-level and public members of a class without internal. Is it possible?

Dear kotlin community,

Recently I started to create a simple DSL on top of apache POI.
And I came across the problem of not being able to author classes for which some members have package level visibility and others public one, as per below:

Before conversion

 public class Foo {

  public void foo1() {

  void foo2() {

After conversion

    class Foo {

        fun foo1() {

        internal fun foo2() {

I’ve read some kt conversations on this topic, and one of the solutions was to have all classes with the package level visibility members in the same file.
I did this but it seems that in that case I cannot mix package level and public level members in the same class.
Is there a good approach for addressing this w/o having internal visibility and another module?

Thank you in advance for your support.


By default Kotlin’s visibility is public. internal corresponds (more or less) to Java’s package-level visibility (it’s more visible actually, but it shouldn’t be a problem).

Hi vbezhenar,

Thank you for your reply.

internal visibility modifier acts more or less like package one if the classes containing internal members resides in a different module.
In my case the classes acts like a basic/small API with internals (internal members) and an exposed interface (public members).
The main requirement for my API is to reside in the same module as its only client.
I can’t tell to the code reviewer I have to create a new module for this tiny API just to handle this case.

Thank you in advance for helping me in this matter.