-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Union types are approximated too often, especially in the REPL #1532
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
Comments
Yes, we widen union types too much as discussed in #1495 For now, you can run the compiler with |
Thank you for explanation. On Thu, Sep 22, 2016 at 11:05 PM, Guillaume Martres <
~Yours, Xuefeng Wu/吴雪峰 敬上 |
Closing since this is unlikely to change for now. As a workaround you can define an identity type and use scala> type Identity[T] = T
// defined alias type Identity = [T] => T
scala> 1: Identity[Int | String]
val res1: Identity[Int | String] = 1 |
union type works well in container type.
but if union type value is not in container, it's result type is Any
and it also doest work for method.
the result type should be union type.
The text was updated successfully, but these errors were encountered: