Closed
Description
Compiler version
main
Minimized code
import language.experimental.captureChecking
trait Ctx
type Context = {*} Ctx
trait Type
abstract class TypeAccumulator[T](implicit protected val accCtx: Context) {
this: {*} TypeAccumulator[T] =>
def apply(x: T, tp: Type): T
def foldOver(x: T, tp: Type): T = ???
}
abstract class TypeTraverser(using Context) extends TypeAccumulator[Unit] {
def traverse(tp: Type): Unit
def apply(x: Unit, tp: Type): Unit = traverse(tp)
protected def traverseChildren(tp: Type): Unit = foldOver((), tp)
}
def main(using ctx: Context): Unit = {
val checker = new TypeTraverser { this: {ctx} TypeTraverser =>
def traverse(tp: Type): Unit = ???
}
}
Output
20 | val checker = new TypeTraverser { this: {ctx} TypeTraverser =>
| ^
| illegal inheritance: anonymous class TypeTraverser {...} inherits conflicting instances of parameterized base class TypeAccumulator.
|
| Direct basetype: TypeAccumulator[Unit]
| Basetype via superclass TypeTraverser: {ctx} TypeAccumulator[Unit]
1 error found
Expectation
This code should compile.