-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cut the Gordian Knot: Don't widen unions to transparent #15642
Commits on Nov 8, 2022
-
Cut the Gordian Knot: Don't widen unions to transparent
The idea is that some unions usually make more sense than others. For instance, if `Apply` and `Ident` are case classes that extend `Tree`, it makes sense to widen `Apply | Ident` to `Tree`. But it makes less sense to widen `String | Int` to `Matchable`. Making sense means: (1) Matches our intuitive understanding, and (2) choosing not to widen would usually not cause errors. To explain (2): In the `Tree` case it might well be that we define an implicits on `Inv[Tree]` for invariant class `Inv`, and then we would not find the implicit for `Inv[Apply | Ident]`. But it's much less likely that we are looking for an implicit of type `Inv[Any]`. This commit does two things: - add logic not to widen a union if the result is a product of only transparent traits or classes. - treat `Any`, `AnyVal`, `Object`, and `Matchable` as transparent.
Configuration menu - View commit details
-
Copy full SHA for f19de96 - Browse repository at this point
Copy the full SHA f19de96View commit details -
Configuration menu - View commit details
-
Copy full SHA for 715b9a6 - Browse repository at this point
Copy the full SHA 715b9a6View commit details -
Configuration menu - View commit details
-
Copy full SHA for fcb9a92 - Browse repository at this point
Copy the full SHA fcb9a92View commit details -
Configuration menu - View commit details
-
Copy full SHA for d4d6aa2 - Browse repository at this point
Copy the full SHA d4d6aa2View commit details -
Configuration menu - View commit details
-
Copy full SHA for a475fa7 - Browse repository at this point
Copy the full SHA a475fa7View commit details -
Configuration menu - View commit details
-
Copy full SHA for d3861ee - Browse repository at this point
Copy the full SHA d3861eeView commit details -
Assume more traits are transparent
- include js.Any and js.Object - include others ...Ops and Is... classes from collections - Change the implementation so that we don't have to load traits or classes that are assumed transparent.
Configuration menu - View commit details
-
Copy full SHA for 32869de - Browse repository at this point
Copy the full SHA 32869deView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6fd96ed - Browse repository at this point
Copy the full SHA 6fd96edView commit details -
Drop js Any and Object from transparent classes
They give test failures, and I don't know enough about the js class hierarchy to be able to fix them with confidence.
Configuration menu - View commit details
-
Copy full SHA for 74c079f - Browse repository at this point
Copy the full SHA 74c079fView commit details
Commits on Nov 9, 2022
-
Update documentation of union types
- Introduce hard and soft unions - Explain how transparency of base traits influences type inference - Drop outdated note on possible future changes
Configuration menu - View commit details
-
Copy full SHA for b2f2db6 - Browse repository at this point
Copy the full SHA b2f2db6View commit details -
Update docs/_docs/reference/new-types/union-types.md
Co-authored-by: Guillaume Martres <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 4a51300 - Browse repository at this point
Copy the full SHA 4a51300View commit details