Skip to content

Error on type inference #11556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flomebul opened this issue Feb 28, 2021 · 1 comment · Fixed by #12847
Closed

Error on type inference #11556

flomebul opened this issue Feb 28, 2021 · 1 comment · Fixed by #12847

Comments

@flomebul
Copy link
Contributor

flomebul commented Feb 28, 2021

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

@abgruszecki
Copy link
Contributor

The real issue seems to be that in the type of g2, we infer Path[Any] but we should infer Path[g.Node].
@smarter feel free to downgrade the issue to an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants