I just checked and if I write class Foo private (x: Int)
, then I do get a private constructor in Scala 3.
However, this isn’t the case in Scala 2, I think the best we could do there is to emit the constructor as ACC_SYNTHETIC
to make it invisible to javac without affecting binary compatibility.