Compiler version
3.7.2
Minimized code
trait Test {
  def incr(): Unit
}
object Test {
  val test = new Test {
    var position: Int = 0
    def incr(): Unit = { position += 1 }
  }
}Output
[warn] -- [E198] Unused Symbol Warning: Test.scala:9:8 
[warn] 9 |    var position: Int = 0
[warn]   |        ^^^^^^^^^^
[warn]   |        unused private member
Expectation
Compiles without warnings.