Skip to content

Infinite compile time with type inference union-typed implicit #830

Closed
@propensive

Description

@propensive

The following appears to send the compiler into an infinite loop, but only when the return type of x is used to infer the type parameter of the call to y:

object C {
  trait X[T]
  implicit def u[A, B]: X[A | B] = new X[A | B] {}
  def y[T](implicit x: X[T]): T = ???
  val x: 1 & 2 | 2 & 3 = y
}

My guess is that the interaction between the type inference of y's parameter T and implicit search is underconstrained. The type expression (1 & 2 | 2 & 3) must contain at least one repeated type (here, 2).

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