Isn’t ‘protected’ has lesser visibility than ‘inte...
# getting-started
h
Isn’t ‘protected’ has lesser visibility than ‘internal’ ? Then why following:
how on this earth?
🙌 1
y
Is the class itself internal? If not, then technically speaking a subclass in another module can see the setter without seeing the getter in the first case, and in the second case someone can see the setter and call it in the same module but without seeing the getter
h
No, Class itself is public
I don't get it. It is throwing errors in both cases meaning that here, visibility modifiers permissiveness depends on usage. But i still don't get it honestly.
y
I think it's because internal and protected aren't necessarily subsets of each other. As in, neither are "more" permissive than the other. They're just not comparable, in a way. I think what you could do here is instead of using
internal
just use a
RequiresOptIn
annotation.
h
Yeah i also reached this conclusion by seeing error in both cases🤣
e
`internal`: unrelated classes in same module can access, subclasses in different module cannot `protected`: unrelated classes in same module cannot access, subclasses in different module can neither is a subset of the other
h
I got it later on By the way, thanks