A long shot, but putting it out there -- looking for a way to provide privacy based on a common relative package scope.
So, for example, is there a way to use private[foo] for packages com.company1.foo and com.company2.foo where each package will have access to the other foo package based on their "foo-ness"
Unlikely, but would be nice, have a private[model] used in dependent sbt projects that could really benefit from such a relative privacy.
You cannot do this. From the language spec (2.9):
The modifier can be qualified with an identifier
C(e.g.private[C]) that must denote a class or package enclosing the definition
So the best you can hope for is a shared common package. For the two given examples, com.company1.foo, and com.company2.foo the most restrictive shared root is com; private[com] would be the best you could do.
I don't think this is possible, since foo is just an alias for one specific fully named package in any given scope.
So to packages with names ending in .foo don't have much more in common than two packages containing the letter e in their names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With