Skip to content

Initialization checker doesn't catch uninitialized object call #9176

Closed
@smarter

Description

@smarter

When running the following code with -Ycheck-init, no warning or error is emitted:

class Foo(val opposite: Foo)
case object A extends Foo(B)
case object B extends Foo(A)
object Test {
  def main(args: Array[String]): Unit = {
    println(A.opposite)
    println(B.opposite)
  }
}

But A ends being used when it's uninitialized:

B
null

I'm not sure if this is a bug or outside the scope of safe initialization?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions