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

Cut the Gordian Knot: Don't widen unions to transparent #15642

Merged
merged 11 commits into from
Nov 9, 2022

Commits on Nov 8, 2022

  1. 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.
    odersky committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    f19de96 View commit details
    Browse the repository at this point in the history
  2. Allow transparent classes

    odersky committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    715b9a6 View commit details
    Browse the repository at this point in the history
  3. Update tests

    odersky committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    fcb9a92 View commit details
    Browse the repository at this point in the history
  4. Fix scalaz test

    odersky committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    d4d6aa2 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    a475fa7 View commit details
    Browse the repository at this point in the history
  6. Update doc page

    odersky committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    d3861ee View commit details
    Browse the repository at this point in the history
  7. 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.
    odersky committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    32869de View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    6fd96ed View commit details
    Browse the repository at this point in the history
  9. 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.
    odersky committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    74c079f View commit details
    Browse the repository at this point in the history

Commits on Nov 9, 2022

  1. 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
    odersky committed Nov 9, 2022
    Configuration menu
    Copy the full SHA
    b2f2db6 View commit details
    Browse the repository at this point in the history
  2. Update docs/_docs/reference/new-types/union-types.md

    Co-authored-by: Guillaume Martres <[email protected]>
    odersky and smarter authored Nov 9, 2022
    Configuration menu
    Copy the full SHA
    4a51300 View commit details
    Browse the repository at this point in the history