Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up#4143: Pseudo-union type inference with type aliases and js.undefined #4145
Conversation
60f37ba
to
b7de868
This passes my tests but causes issues with diverging implicit expansion in some other projects where I've tried it. I'll take a closer look this week-end. |
b7de868
to
a756c7f
…ined
a756c7f
to
7b4b0e9
I added a second implicit conversion and some other tests to cover more complex type aliases. I think this is ready for review. |
I really don't like the left-right asymmetry of the new rules. Previously, all rules where symmetric in the sense that if there was a rule for I am also wary about the fact that you had to add For those two reasons, I don't think this is the best way to go to mitigate the type inference issue. |
I agree that not having the symmetry is not elegant, I used this more as a direct solution to the specific problem that occured with type aliases and I understand your concerns about these additions breaking some other things downstream. Do you have some kind of community build for Scala.js that might help us assess this? Otherwise, it is probably wiser to close this and try to fix the inference issue in the Scala compiler itself. That will probably be above my pay-grade though! |
No, we don't. We rely on an extensive test suite instead, which is usually good enough. But for cases of tricky type inference like this, a test suite can never be enough because of many unknown unknowns about interactions with surrounding code. That's why we have to be extra careful. I'm also particularly wary here, compared to other changes we've done in the past to
and redundant implicit definitions can easily cause divergences or ambiguities.
Maybe fixing the type inference is above you pay-grade (I don't know your background nor your time availabilities), but if you got this far, I'm sure you could create a reproduction to post as an issue on scala/bug |
frobinet commentedJul 30, 2020
•
edited
This PR fixes #4143, an issue with type inference for pseudo-union types
scala.scalajs.js.|
whenNothing
is the first type parameter. This is especially useful when infering forjs.undefined
(see #4143).Since Scala 3 will include proper union types, I've limited the changes to the strict minimum to allow
js.undefined
to work with type aliases like it did in Scala.js 0.6.x.This is my first contribution to Scala.js, so there are probably issues with this PR. Feel free to point them out!