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

Always use baseType when constraining patternTp with scrutineeTp #20032

Merged
merged 1 commit into from
Apr 6, 2024

Commits on Mar 27, 2024

  1. Always use baseType when constraining patternTp with scrutineeTp

    In the following example:
    ```
    type Cond[B <: Boolean] <: Tuple2[String, String] = B match ...
    type Decoded[B <: Boolean] = Cond[B] match
      case (h1, _) => Int
    ```
    When constraining the `(h1, _)` pattern with `Cond[B]`,
    we incorrectly assumed we could constrain h1 with B,
    because `Cond[B]` is an applied type of which the baseType is Tuple2.
    
    The issue can be fixed in constrainSimplePatternType
    by obtaining the baseType for both the patternTp and scrutineeTp,
    with the most general base of the two.
    
    So in the above example, we wound constrain `B` with String
    by obtaining `(String, String)` from `Cond[B]`.
    EugeneFlesselle committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    104ee62 View commit details
    Browse the repository at this point in the history