Member value of mixin trait missing a concrete super implementation

Viewed 158

Given code snippet:

abstract class A {
  protected val x: Int
}
trait B extends A {
  println(x)
}
case class C(override protected val x: Int) extends A with B

I encountered the following problems:

  1. The code compiles if I'm pasting the whole snippet into the scala REPL using :paste mode; however it doesn't if I paste each class block one by one (i.e., firstly paste A definition, then B, then C). What's happening here?

  2. When it doesn't compile, the compiler emits the error:

    scala> case class C(override protected val x: Int) extends A with B
    <console>:13: error: Member value x of mixin trait iw$B is missing a concrete super implementation.
           case class C(override protected val x: Int) extends A with B
                      ^
    

    I don't understand what it means exactly. Why x in B misses a concrete implementation? Didn't C provided it?

I've tested both on Scala 2.12.11 and 2.13.3, on macOS 10.15.7

Edit: Here's a gif for what I mean for pasting one by one. And the error is only triggered if you paste one-by-one.

enter image description here

0 Answers
Related