Closed
Description
scala> case class Cell[@specialized T](x:T) { private[this] var v = x; def read = v }
residual specialized constructor statements: ListBuffer(Cell$mcV$sp.this.v$mcV$sp = scala.runtime.BoxedUnit.UNIT)
residual specialized constructor statements: ListBuffer(Cell$mcZ$sp.this.v$mcZ$sp = Cell$mcZ$sp.this.x())
residual specialized constructor statements: ListBuffer(Cell$mcB$sp.this.v$mcB$sp = Cell$mcB$sp.this.x())
residual specialized constructor statements: ListBuffer(Cell$mcS$sp.this.v$mcS$sp = Cell$mcS$sp.this.x())
residual specialized constructor statements: ListBuffer(Cell$mcC$sp.this.v$mcC$sp = Cell$mcC$sp.this.x())
residual specialized constructor statements: ListBuffer(Cell$mcI$sp.this.v$mcI$sp = Cell$mcI$sp.this.x())
residual specialized constructor statements: ListBuffer(Cell$mcJ$sp.this.v$mcJ$sp = Cell$mcJ$sp.this.x())
residual specialized constructor statements: ListBuffer(Cell$mcF$sp.this.v$mcF$sp = Cell$mcF$sp.this.x())
residual specialized constructor statements: ListBuffer(Cell$mcD$sp.this.v$mcD$sp = Cell$mcD$sp.this.x())
defined class Cell
scala> Cell(7) read
res5: Int = 0
Result should be 7, not 0. Error is not specific to repl. There is no error if one uses private
instead of private[this]
and it has to be a case class.