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

[WIP] Match Type with no cases should not reduce to ErrorType #19953

Closed
wants to merge 4 commits into from

Commits on Mar 15, 2024

  1. Add regression tests

    EugeneFlesselle committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    c79c664 View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2024

  1. Revert "ErrorType instead of throwing in match type "no cases""

    This reverts commit 9ae1598
    
    Note that the changes in Typer:
    ```
    val unsimplifiedType = result.tpe
    simplify(result, pt, locked)
    result.tpe.stripTypeVar match
      case e: ErrorType if !unsimplifiedType.isErroneous =>
        errorTree(xtree, e.msg, xtree.srcPos)
      case _ => result
    ```
    cannot be reverted yet since the MatchReducer now also reduces to an `ErrorType` for MatchTypeLegacyPatterns, introduced after 9ae1598.
    EugeneFlesselle committed Mar 17, 2024
    Configuration menu
    Copy the full SHA
    b2c544a View commit details
    Browse the repository at this point in the history
  2. Update check-files and remove i18488.scala

    i18488.scala was only passing because of the bug in the MatchReducer,
    as we can see in the subtyping trace:
    ```
    ==> isSubType TableQuery[BaseCrudRepository.this.EntityTable] <:< Query[BaseCrudRepository.this.EntityTable, E[Option]]?
      ==> isSubType Query[BaseCrudRepository.this.EntityTable, Extract[BaseCrudRepository.this.EntityTable]] <:<
                    Query[BaseCrudRepository.this.EntityTable, E[Option]] (left is approximated)?
        ==> isSubType E[Option] <:< Extract[BaseCrudRepository.this.EntityTable]?
          ==> isSubType [T[_$1]] =>> Any <:< Extract?
            ==> isSubType Any <:< Extract[T]?
              ==> isSubType Any <:< T match { case AbstractTable[t] => t } <: t (right is approximated)?
                ==> isSubType Any <:< <error Match type reduction failed since selector T
                                       matches none of the cases
                                       case AbstractTable[t] => t> (right is approximated)?
                <== isSubType Any <:< <error Match type reduction failed since selector T
                                       matches none of the cases
                                       case AbstractTable[t] => t> (right is approximated) = true
              <== isSubType Any <:< T match { case AbstractTable[t] => t } <: t (right is approximated) = true
            <== isSubType Any <:< Extract[T] = true
          <== isSubType [T[_$1]] =>> Any <:< Extract = true
          ...
        <== isSubType Extract[BaseCrudRepository.this.EntityTable] <:< E[Option] = true
      <== isSubType Query[BaseCrudRepository.this.EntityTable, Extract[BaseCrudRepository.this.EntityTable]] <:<
                    Query[BaseCrudRepository.this.EntityTable, E[Option]] (left is approximated) = true
    <== isSubType TableQuery[BaseCrudRepository.this.EntityTable] <:< Query[BaseCrudRepository.this.EntityTable, E[Option]] = true
    ```
    EugeneFlesselle committed Mar 17, 2024
    Configuration menu
    Copy the full SHA
    ed5ddfe View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    be4065e View commit details
    Browse the repository at this point in the history