Package declarations, such as imports, give you access to everything inside them. Therefore when you
package foo.bar.my_package
then you have everything that would be if you did
import foo.bar.my_package._
In addition, declaring a package on a single line means that everything below applies to this package:
package foo.bar.my_package { package my_sub { class MyClass { var x: SomeType = _ } } }
(which is equivalent to:
package foo.bar.my_package package my_sub class MyClass { var x: SomeType = _ }
)
so that you can see how the contents of foo.bar.my_package should be in scope in this case. Otherwise, you only have the contents of foo.bar.my_package.my_sub , which does not include SomeType .
source share