Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

private[foo] apply to any foo based package?

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.

like image 631
virtualeyes Avatar asked Dec 06 '25 01:12

virtualeyes


2 Answers

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.

like image 121
Richard Sitze Avatar answered Dec 08 '25 16:12

Richard Sitze


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.

like image 30
Jens Schauder Avatar answered Dec 08 '25 14:12

Jens Schauder