It is not possible to create private classes with the same name in different modules

Official documents on visibility modifiers in Kotlin say that package-level elements marked privateare visible only in the module in which they are declared.

So the class Adeclared in Module1.ktdoes not appear in Module2.kt. But if I try to add to Module2.ktmy own class A, I get an error Redeclaration: A.

Since I can't access the class Module2.ktbefore Module1 A, why can't I use the name A?

+4
source share
1 answer

" Kotlin, " ( - Kotlin).

Module1.kt Module2.kt , , , :

  • , .
  • , , private class A.

, . a class , , . (, , ) .

+8

Source: https://habr.com/ru/post/1628833/


All Articles