Skip to content
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

Eta-expansion too conservative wrt dependent method type #7815

Closed
scabug opened this issue Sep 5, 2013 · 2 comments
Closed

Eta-expansion too conservative wrt dependent method type #7815

scabug opened this issue Sep 5, 2013 · 2 comments

Comments

@scabug
Copy link

@scabug scabug commented Sep 5, 2013

Consider this snippet:

trait Foo[A] {
  type Repr
  def f(a: A): Repr
}
 
object Foo {
  type Aux[A, B] = Foo[A] { type Repr = B }
}
 
object Main extends App {
  def mapWithFoo[A, B](as: List[A])(implicit foo: Foo.Aux[A, B]) =
    as map foo.f
}

scalac complains about that it can't convert the method to a function value, because it deems it to have a dependent type. At first glance, that seems correct. However, the following works:

  def mapWithFoo[A, B](as: List[A])(implicit foo: Foo.Aux[A, B]) =
    as map (a => foo.f(a))

As you can see, the "dependent" return type Repr is actually bound to B, so eta-expansion could be done.

Use case: shapeless 2.0.0-M1. Previously, the FooAux types were proper traits, so no dependent types involved. Now, they are type aliases in the style of Foo.Aux.

Related to #4751.

@scabug
Copy link
Author

@scabug scabug commented Sep 5, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7815?orig=1
Reporter: Lars Hupel (larsrh)
Affected Versions: 2.10.2, 2.11.0-M4

@scabug
Copy link
Author

@scabug scabug commented Sep 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants