Skip to content

Cyclic type involving LazyRef is not detected and crash in Pickler. #2941

Closed
@gsps

Description

@gsps

The following example triggers an infinite recursion in TypeAssigner.avoid(). The call to avoid() originates from ensureNoLocalRefs, and, further up the call stack, from the handling of match cases (Typer.scala:951). The actual avoidance is performed on a LazyRef, which is likely at the heart of the problem.

trait FooBase {
  type Bar >: Null <: BarBase { type This <: FooBase.this.Bar }
  type This >: this.type <: FooBase { type This <: FooBase.this.This }

  def derived(bar: Bar): This = ???
}

trait BarBase {
  type This >: Null <: BarBase { type This <: BarBase.this.This }
}

object Test {
  def bad(foo: FooBase): FooBase = foo match {
    case foo: FooBase =>
      foo.derived(???)  // Triggers infinite loop in TypeAssigner.avoid()
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions