illegal cyclic reference involving object scala and case class

258 Views Asked by At

Why do I get an error saying illegal cyclic reference? I thought objects in scala are like singleton and act as a container and cannot be instantiated. Why it is cyclic? How to fix this error without moving case class Baz out of object Bar?

trait Foo[T]

object Bar extends Foo[Bar.Baz] {
  case class Baz()
}

Error:

illegal cyclic reference involving object Bar
object Bar extends Foo[Bar.Baz] {
0

There are 0 best solutions below