-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#10878Description
The bug was firstly asked on stackoverflow. Here is the reference post. Here's a gist to reproduce the issue, created by @DmytroMitin.
Tested on Scala 2.12.11, 2.13.3, 2.13.4.
reproduction steps
-
In file
A.scala
, we havepackage mixintest.a abstract class A { protected val x: Int }
-
In file
B.scala
, we havepackage mixintest.b import mixintest.a.A trait B extends A { println(x) }
-
In file
C.scala
, we havepackage mixintest.c import mixintest.a.A import mixintest.b.B case class C(override protected val x: Int) extends A with B
-
build.sbt
ThisBuild / scalaVersion := "2.13.3"
-
run
compile
in sbt shell, emitting the following error:
sbt:scala> compile
[info] Compiling 3 Scala sources to /Users/naitree/Documents/try/scala/target/scala-2.13/classes ...
[error] /Users/naitree/Documents/try/scala/src/main/scala/C.scala:4:12: Member value x of mixin trait B is missing a concrete super implementation.
[error] case class C(override protected val x: Int) extends A with B
[error] ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed Nov 26, 2020, 5:13:32 PM
sbt:scala>
problem
When A
, B
, C
are defined in the same package, it compiles successfully. But it won't compile if they reside in different packages.
By the way, I can workaround the bug, by re-declaring the abstrat member in B
trait:
package mixintest.b
import mixintest.a.A
trait B extends A {
protected val x: Int // workaround
println(x)
}
DmytroMitin