Skip to content

Type Inference Issues in Latest Version of Dotty #7149

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 Sep 1, 2019 · 5 comments
Closed

Type Inference Issues in Latest Version of Dotty #7149

adamgfraser opened this issue Sep 1, 2019 · 5 comments

Comments

@adamgfraser
Copy link
Contributor

We're seeing some type inference issues in trying to compile ZIO against the latest version of Dotty that don't entirely make sense to me. See compilation errors here. It appears that two of the issues can be minimized to the following:

trait ZIO[-R, +E, +A] { self =>

  final def +++[R1, B, E1 >: E](that: ZIO[R1, E1, B]): ZIO[Either[R, R1], E1, Either[A, B]] =
    for {
      e <- ZIO.environment[Either[R, R1]]
      r <- e.fold(self.map(Left(_)) provide _, that.map(Right(_)) provide _)
    } yield r
    // Found:    (Left[A, Any] | Right[Any, B])(r)
    // Required: Either[A, B]

  def flatMap[R1 <: R, E1 >: E, B](f: A => ZIO[R1, E1, B]): ZIO[R1, E1, B] = ???

  def map[B](f: A => B): ZIO[R, E, B] = ???

  def provide[R](R: R): ZIO[Any, E, A] = ???
}

object ZIO {
  def environment[R]: ZIO[R, Nothing, R] = ???
}

The other two also relate to types being inferred as Any and are here and here.

When you have the chance could you please advise whether there is an issue here or something we need to be doing differently? Thanks!

Copying @jdegoes.

@jdegoes
Copy link

jdegoes commented Sep 1, 2019

We can ask @smarter and open a ticket in Dotty.

In this fold case we can probably solve workaround it by adding a type annotation to fold, e.g. fold[X], where X = IO[E1, Either[A, B]].

Ah, this is the Dotty repo. 😆 Nevermind, then.

@adamgfraser
Copy link
Contributor Author

Yes confirmed that the fold case compiles using an explicit type annotation, though I don't think that should be necessary.

@odersky
Copy link
Contributor

odersky commented Sep 3, 2019

I think I might have a fix. Once #7161 is green, can you check whether it's sufficient to solve your problems? Thanks!

@adamgfraser
Copy link
Contributor Author

Will do! Thanks for being so responsive on this! Really appreciate it!

@odersky odersky closed this as completed in 85962b1 Sep 3, 2019
@adamgfraser
Copy link
Contributor Author

@odersky Just wanted to confirm that we are now able to compile against the latest nightly version of Dotty. Thanks again for your help with this and for everything you and your team are doing to build the next generation of Scala!

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

4 participants