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

Union types don't get widened within a type lambda #9479

Closed
LukaJCB opened this issue Aug 1, 2020 · 0 comments · Fixed by #9488
Closed

Union types don't get widened within a type lambda #9479

LukaJCB opened this issue Aug 1, 2020 · 0 comments · Fixed by #9488

Comments

@LukaJCB
Copy link

LukaJCB commented Aug 1, 2020

Minimized code

trait Applicative[F[_]]

def traverse[F[_]: Applicative, A, B](as: List[A])(f: A => F[B]) = ???

implicit def eitherApplicative[A]: Applicative[[X] =>> Either[A, X]] = ???

traverse(List(1, 2))(i => if (true) Right(i) else Left(i))

Output

no implicit argument of type Applicative[([X0] =>> Right[Nothing, X0] | Left[Int, X0])] was found for an implicit parameter of method traverse

Expectation

This should compile fine as it does in Scala 2.

smarter added a commit to smarter/dotty that referenced this issue Aug 3, 2020
In the same way that when instantiating a type variable to `A | B` we
first try to replace the union type by a non-union upper bound, we now
also try to widen `[X] =>> A | B` to a type lambda whose body is not a
union.
@nicolasstucki nicolasstucki linked a pull request Aug 5, 2020 that will close this issue
odersky added a commit that referenced this issue Aug 6, 2020
Fix #9479: Widen unions in inferred type lambdas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant