when main constructor parameter has neither val
nor var
applied to it then it’s implicitly private
and IIRC can be even completely erased if it’s not needed after class initialization. other types of class members (including types) are implicitly public.
no, it’s not possible. your workaround is making a non-private field and exposing a path-dependent type based on that non-private field (that’s the crucial part). private[test]
is also not fully private as it’s visible outside of the class, so there’s a way to meaningfully use the exposed type, so there’s no need to throw a compilation error.
here’s a simpler example showing the same problem:
class Exposer(param: Int): // no var or val, so `param` is implicitly private
type ExposedType = param.type // compilation error here
def expose: ExposedType = param
val exposer = Exposer(5)
val number: exposer.ExposedType = exposer.expose
println(number)
yep, probably our posts should be moved to your original thread.