Skip to content

Type inference regression versus Scala 2 #8111

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
adamgfraser opened this issue Jan 28, 2020 · 0 comments
Closed

Type inference regression versus Scala 2 #8111

adamgfraser opened this issue Jan 28, 2020 · 0 comments
Assignees

Comments

@adamgfraser
Copy link
Contributor

minimized code

object Example extends App {
  
  def assertLazy[A, B](f: (=> A) => B): Boolean = ???
  
  def fromEither[E, A](eea: => Either[E, A]): Unit = ???
  
  lazy val result = assertLazy(fromEither)
  
  println("It compiles!")
}
Found:    Any
Required: Either[Any, Any]

expectation

I would expect this code to compile as it does on Scala 2. assertLazy is completely polymorphic in its type other than being by name, which fromEither satisfies, so this should work. The issue appears to be related to the fact that the argument to fromEither has two type parameters. If I try it with an argument with only one parameter it works correctly.

@odersky odersky self-assigned this Jan 29, 2020
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 7, 2020
When we reach out to get the callee type, we might get an error, e.g.
if the callee is overloaded. Example:
```
ch => sb.append(ch)
```
Here we might want to call calleeType to find the argument type
of `sb.append` in order to use this type as the type of `ch`. But
this fails since `append` is overloaded on StringBuffer.

Prevously this did not matter since we called calleeType only as a last
effort, so if it failed the whole typing failed. But with the changes
forseen for fiing scala#8111 we need to be able to compute calleeType and
retract it if it does not work.
odersky added a commit that referenced this issue Feb 16, 2020
Fix #8111: Use better algorithms to infer parameter types
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