The following snippet of code:
trait Define :
type Test
def work: Unit
class Class(define: Define) :
type Test = define.Test
def work = define.work
gives a compiler error:
non-private type Test in class Class refers to private value define
in its type signature = Class.this.define.Test
But why is that? What is the risk here? It seems to me that we make parts of private values public all the time, for example the method def work
. When making define
public with a val
:
class Class (val define: Define)
that of course helps, but exposes the rest of define
at the same time.