Skip to content

Type inference problem with dependent method types #12534

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
odersky opened this issue May 19, 2021 · 0 comments · Fixed by #12535
Closed

Type inference problem with dependent method types #12534

odersky opened this issue May 19, 2021 · 0 comments · Fixed by #12535
Milestone

Comments

@odersky
Copy link
Contributor

odersky commented May 19, 2021

Minimized example

The test is a version of i8802.scala, with an explicit implicit argument.

trait Foo[A1, B1] {
  type Out
}

object Test {

  type Bar[A2]

  def unit: Bar[Unit] = ???
  def product[A3, B3](fst: Bar[A3], snd: Bar[B3])(implicit foo: Foo[A3, B3]): Bar[foo.Out] = ???

  implicit def foo[A4]: Foo[A4, Unit] { type Out = A4 } = ???

  def check[A5](bar: Bar[A5])(a: A5): Unit = {}

  check(product(unit, unit)) // ok  
  check(product(unit, unit)(summon[Foo[Unit, Unit]]))(()) // error if implicit argument is given explicitly
}

Output

-- [E007] Type Mismatch Error: ../pos/i8802a.scala:17:27 -----------------------
17 |  check(product(unit, unit)(summon[Foo[Unit, Unit]]))(()) // error
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |        Found:    Test.Bar[Unit]
   |        Required: Test.Bar[(Foo[Unit, Unit] & Singleton)#Out]

longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: ../pos/i8802a.scala:17:54 -----------------------
17 |  check(product(unit, unit)(summon[Foo[Unit, Unit]]))(()) // error
   |                                                      ^^
   |                             Found:    Unit
   |                             Required: (Foo[Unit, Unit] & Singleton)#Out

Expectation

Should compile

odersky added a commit to dotty-staging/dotty that referenced this issue May 19, 2021
odersky added a commit to dotty-staging/dotty that referenced this issue May 19, 2021
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants