Skip to content

Error on type inference #11556

Closed
Closed
@flomebul

Description

@flomebul

Scala version 3.0.0-RC1

Minimized code

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 }

case class Path[+E](e: E)
type Query[-I, +O] = Traverser[Path[I], Path[O]]

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

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

object Issue11556:
  val q1: Query[Nothing, Node] = nodesQ ~> outsQ
  implicitly[q1.type <:< Query[Nothing, Node]]

  val q2 = nodesQ ~> outsQ
  val q3: Query[Nothing, Node] = q2
  implicitly[q2.type <:< Query[Nothing, Node]]
end Issue11556

Output

  val q3: Query[Nothing, Node] = q2
Found:    (Issue99991.q2 : Traverser[Path[Nothing], Path[Any]])
Required: Query[Nothing, graph.Node]

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

Expectation

No such errors

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions