I am having a hard time understanding Private[this] when this Bind to a package vs Private[PackageName]
E.g.
This works fine:
package scopeA {
private[scopeA] class PrivateClass1
class PrivateClass2 extends PrivateClass1
}
But this does not
package scopeA {
private[this] class PrivateClass1
class PrivateClass2 extends PrivateClass1 //private class PrivateClass1 escapes its defining scope as part of type scopeA.PrivateClass1
}
However if i modify the second one as such:
package scopeA {
private[this] class PrivateClass1
private class PrivateClass2 extends PrivateClass1
}
private[this]
or private
, have the same effect in the last scenario.
I can see the difference, but i can't put proper words on it. Hence my question, what is the meaning of Private[this]
when this bind to a package ? and is it different from private[PackageName]
, what's the exact difference between the two ?
There is something about escaping the scope that i am not sure to follow, why would it be ok with package name but not this ?