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
Surprising interaction of eta-expansion and implicit argument passing #7641
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7641?orig=1 |
Leif Warner (pdxleif) said: |
Leif Warner (pdxleif) said: |
@retronym said: object Test {
trait TC[_]
implicit val tcInt: TC[Int] = ???
def bar[T](t:T)(implicit x: TC[T]): Int = 0
def foo[B](f: Int => B) {}
foo (x => bar(x)) // okay
foo (bar) // fails
} |
@retronym said:
Eta expansion drives the type of the parameter from the
In the example about, that gives: (t: T) => bar(t) where I'm not sure yet whether we can make the two behave uniformly. I'll leave this ticket open in the hope that someone finds a way. For future reference, the interesting stuff is in Even though the expected type is |
Leif Warner (pdxleif) said: Other cases: Some(Some("yes")).map(_.orNull) // works
def orNull[A](o:Option[A])(implicit ev: <:<[Null,A]): A = o getOrElse null
Some(Some("yes")).map(orNull) // doesn't |
@adriaanm you might want to look at this in your work on eta-expansion |
e.g.
(using scalaz's Monoid typeclass) or
, then
(or bar) gives "No implicit Monoid defined for T" (or Ordering).
Variants that do work:
Also, this doesn't appear to affect functions using [T : ClassTag] - that's resolved just fine.
The text was updated successfully, but these errors were encountered: