Default visibility rules


#1

Hello,

Checked the kotlin reference but haven’t found information about default class/class members visbility rules, e.g. is it guaranteed that a class declared like below will be public?

data class Text(val startOffset : Int, val endOffset : Int) : Setting()

Please clarify.

Regards, Denis


#2

By default, everything gets visibility internal, which is "visible inside the same module". "Public" should be specified explicitly if you want to access something from another module


#3

Thanks, it's worth to reflect that at the reference as well

Denis


#4

Are you sure?

How come ctrl+o or ctrl+i for public methods don’t add “public” then?

I have been adding “public” manually for overrides, but it seems to work without it.
Is that a bug or something specific to overrides?


#5

When you override a member, you don't have to specify visibility, it will be inherited from the base class by default.