Skip to content

Error on type inference #15864

Closed
Closed
@flomebul

Description

@flomebul

Compiler version

3.1.3

Minimized code

A similar issue (#11556) was already corrected several month ago (#12847)

object Issue15864:
  type Traverser[-I, +O] = I => LazyList[(O)]
  extension[I, O](ta: Traverser[I, O])
    def ~[P](tb: Traverser[O, P]): Traverser[I, P] = ???

  class Graph { class Node; class Link }
  
  case class Path[+E](e: E)
  type Query[-U, +V] = Traverser[Path[U], Path[V]]

  def nodesQ(using g: Graph): Query[Nothing, g.Node] = ???
  def outsQ(using g: Graph): Query[g.Node, g.Node] = ???

  object aGraph extends Graph
  import aGraph._
  given aGraph.type = aGraph

  val q1: Query[Nothing, Node] = nodesQ ~ (outsQ ~ outsQ)
  implicitly[q1.type <:< Query[Nothing, Node]]

  val q2 = nodesQ ~ (outsQ ~ outsQ)
  implicitly[q2.type <:< Query[Nothing, Node]]

  val q3: Query[Nothing, Node] = q2
end Issue15864

Output

Cannot prove that (asuivre.Issue15864.q2 : 
  asuivre.Issue15864.Traverser[asuivre.Issue15864.Path[Nothing], 
    asuivre.Issue15864.Path[Any]
  ]
) <:< asuivre.Issue15864.Query[Nothing, asuivre.Issue15864.aGraph.Node].
  implicitly[q2.type <:< Query[Nothing, Node]]

Expectation

Supposed to compile without error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions