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:
The code compiles if I'm pasting the whole snippet into the scala REPL using
:pastemode; however it doesn't if I paste each class block one by one (i.e., firstly pasteAdefinition, thenB, thenC). What's happening here?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
xinBmisses a concrete implementation? Didn'tCprovided 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.
