https://kotlinlang.org logo
#announcements
Title
# announcements
j

jtonic

10/11/2017, 5:15 AM
Hi everyone, Is it possible (and if yes what is the best approach) of having classes with both package level visibility members and public members without internal and a new module?
Copy code
public class Foo {
public void foo1() {}
void foo2() {}
}
Copy code
public class Fee {
public void fee1() {}
void fee2() {}
}
🤔 1
g

gildor

10/11/2017, 5:23 AM
But this is Java
😐 1
k

karelpeeters

10/11/2017, 8:50 AM
Doesn't is just work to mark some functions
internal
?
j

jtonic

10/11/2017, 6:33 PM
Hi, They are java but I wanted to emphasize what I would like to get in kotlin, all this w/o having a new module and internal visibility modifier. As far as I understood having all classes as private in the same file doesn’t allow to have public members.
k

karelpeeters

10/11/2017, 8:09 PM
I don't really undestand, you want private classes to have public fields? How would that every work?
j

jtonic

10/12/2017, 4:45 AM
Hi Karel, No, I don’t want private classes with public fields, I am wondering if package visibility from java has a corresponding in kotlin, but w/o using a internal and having a new module. I really do not completely understand the reason behind not allowing this in kt. Java code.
Copy code
module http
package http.dsl
public class Tag {
  public void add subTag()  {}
  void process() {}
}
package http.core
public class HttpBuilder  {

  public class build() {
   new Tag().addSubTag()
   new Tag().process() // does not compile, no autocomplete for it.
 }
}
g

gildor

10/12/2017, 4:55 AM
package visibility from java has a corresponding in kotlin
Kotlin doesn’t have package visibility
j

jtonic

10/12/2017, 5:15 AM
Thank you very much Andrey for the information. But is there an approach to do what I am intending to do in Kotlin? I am trying to convince my colleagues to use kotlin in production code (currently we are using it in tests) and this restriction combined with not being allowed to use late init for primitives (in fact in our case is the Integer wrapper) makes my colleagues/reviewers to step a bit back. Thank you Tony
g

gildor

10/12/2017, 5:18 AM
I saw comment from Andrey Breslav, that Kotlin Team probably reconsider decision about package visibility. For now you can use only internal + modules or keep code in the same file. None of them are direct replacement of course
j

jtonic

10/12/2017, 7:11 PM
That will be great. Thank you very much for the information and support.