Skip to content

Type inference issue in presence of implicits and path-dependent types #10161

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
julienrf opened this issue Nov 3, 2020 · 0 comments · Fixed by #10924
Closed

Type inference issue in presence of implicits and path-dependent types #10161

julienrf opened this issue Nov 3, 2020 · 0 comments · Fixed by #10924
Milestone

Comments

@julienrf
Copy link
Contributor

julienrf commented Nov 3, 2020

Minimized code

object Incompat2 {
  trait Context { type Out }

  object Context {
    def foo(implicit ctx: Context): Option[ctx.Out] = ???

    def bar(implicit ctx: Context): (Option[ctx.Out], String) = (foo, "foo")
  }
}

Output

7 |    def bar(implicit ctx: Context): (Option[ctx.Out], String) = (foo, "foo")
  |                                                                ^^^^^^^^^^^^
  |                                       Found:    (Option[Any], String)
  |                                       Required: (Option[ctx.Out], String)

Expectation

The code compiles.

It does compile if we pass the implicit parameter explicitly, though:

object Incompat2 {
  trait Context { type Out }

  object Context {
    def foo(implicit ctx: Context): Option[ctx.Out] = ???

    def bar(implicit ctx: Context): (Option[ctx.Out], String) = (foo(ctx), "foo") // note: foo(ctx)
  }
}

Probably a similar test case can be found in https://github.com/mlachkar/scala-migrat3/pull/22

Maybe similar issues: #8991, #8882

odersky added a commit to dotty-staging/dotty that referenced this issue Dec 27, 2020
The previous treatment could instantiate a wildcard type to a type that violated
constraint satisfiability.

Fixes scala#10161
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

2 participants