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

Support Union types in covariant positions #82

Open
bishabosha opened this issue Apr 17, 2020 · 2 comments
Open

Support Union types in covariant positions #82

bishabosha opened this issue Apr 17, 2020 · 2 comments
Labels
enhancement topic:tasty/scala2 Scala 2 implementation of TASTy unpicking

Comments

@bishabosha
Copy link
Member

There is no reason why the return type of a function producing a union type can't be erased to its lub.

There is an issue however with supplying widened unions to dotty methods, unless more work is done to the compiler to enforce precision, such as adapting to something precise but is then erased, like scala.js union

@bishabosha
Copy link
Member Author

@sjrd

@sjrd
Copy link

sjrd commented Apr 17, 2020

My idea for union types is to basically upstream a version of Scala.js' union type into scala/scala, making sure that it is entirely erased away, so that forward bin compat is not an issue (or, failing that, to put it hidden in dotty-library, which will always be on the classpath when depending on a dotty-compiled library).

We would just have to special-case erasure so that A | B erases the same way as it does on dotty (i.e., to the LUB of A and B) rather than Object.

Other than that, there is no change required to the type system, since it is entirely driven by implicit conversions with implicit proof derivations.

We could then have the tasty reader translate dotty's true | into that fake |.

@bishabosha bishabosha added enhancement topic:tasty/scala2 Scala 2 implementation of TASTy unpicking labels Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement topic:tasty/scala2 Scala 2 implementation of TASTy unpicking
Projects
None yet
Development

No branches or pull requests

2 participants