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

Run all MatchType reduction under Mode.Type #17937

Merged
merged 1 commit into from
Jun 23, 2023

Commits on Jun 20, 2023

  1. Run all MatchType reduction under Mode.Type

    There are a number of calls to ".simplified", which changes behaviour
    based on Mode.Type.  It does _less_ under Mode.Type, so we
    conservatively call it all under Mode.Type.
    
    Transcribing and paraphrasing from smarter's comment in
    scala#16408 (comment) :
    
    Type erasure assumes method signatures aren't simplified, since
    simplification logic is implementation-defined.  For instance, some
    intersection types can be simplified down, but intersection types and
    their simplification can erase to different types - prefering classes
    over traits, for instance (for Java interop, as it matches Java's
    erasure).
    
    Also note, simplify doesn't simplify intersections and unions in Type
    mode.  But Match Types will cache their reduction without considering
    the type mode as a cache input, thus the simplified reduction leaks even
    when called in Type mode.
    
    So we call simplified in Mode.Type, in both cases (another desire), so
    only that result is cached instead.
    
    Using normalise doesn't work because, for example, that doesn't
    normalise match types that are applied type args (e.g. args of Pair).
    And not caching the result of those reductions means that they'll get
    repeat over and over.
    dwijnand committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    f90d2e7 View commit details
    Browse the repository at this point in the history