Skip to content

Fail to infer parameter types of eta-expanded anonymous functions #3945

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
biboudis opened this issue Jan 30, 2018 · 0 comments
Closed

Fail to infer parameter types of eta-expanded anonymous functions #3945

biboudis opened this issue Jan 30, 2018 · 0 comments

Comments

@biboudis
Copy link
Contributor

In the following example I compose int with int.

object Test {
  def int[A](k: String => A)(s: String)(x: Int): A = ???

  // composing directly: ok in scalac, error in dotc
  val c: (String => String) => (String) => (Int) => (Int) => String = (int[Int => String] _).compose(int[String] _) 

  // unwrapping composition: ok in scalac, ok in dotc
  val q: (String => Int => String) => (String) => (Int) => (Int => String) = int[Int => String]
  val p: (String => String) => (String) => (Int) => String = int[String]
  val c2: (String => String) => (String) => (Int) => (Int) => String = q.compose(p) 
}

Doing it directly raises an inference error for both parameters of the anonymous function in dotty with the following error:

error missing parameter type

The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type: class dotty.tools.dotc.typer.ProtoTypes$AnyFunctionProto$
Missing type for parameter s
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 11, 2018
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 11, 2018
biboudis pushed a commit that referenced this issue Feb 15, 2018
Fix #3945: Fix eta expansion for partially applied methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants