Closed
Description
Using a private constructor with case class
es cause other methods to be considered private.
Repro 1:
case class X3 private (foo: Int)
val x = X3(1)
trigger:
constructor X3 cannot be accessed as a member of X3
Repro 2:
object X2 {
def apply(
foo: Int,
bar: String = ""
) = new X2(foo, bar)
}
case class X2 private (
foo: Int,
bar: String = ""
)
val x = X2(1)
x.copy(1, "2")
trigger:
method copy in class X2 cannot be accessed as a member of X2
Both examples compiles with scalac 2.12 because only the canonical constructor is affected by the restriction of visibility.
i.e. both the apply
in the companion object and the copy
method should be accessible.
Metadata
Metadata
Assignees
Labels
No labels