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

Fix specifity comparison for extensions in polymorphic givens #13509

Merged
merged 3 commits into from Sep 16, 2021

Commits on Sep 11, 2021

  1. Small refactorings related to TyperState

    - Add Context#withTyperState
    - Add a committable parameter to TyperState#fresh
    smarter committed Sep 11, 2021
    Configuration menu
    Copy the full SHA
    5ddd670 View commit details
    Browse the repository at this point in the history
  2. TyperState#mergeConstraintWith: use the correct context

    Previously, the code in the closure passed to `comparing` could have
    been using the wrong context. I don't think this happened in practice so
    far because comparingCtx was always equal to ctx but it will matter in the
    next commit.
    smarter committed Sep 11, 2021
    Configuration menu
    Copy the full SHA
    be1b6a1 View commit details
    Browse the repository at this point in the history
  3. Fix specifity comparison for extensions in polymorphic givens

    When we compare polymorphic methods for specificity, we replace their
    type parameters by type variables constrained in the current
    context (see isAsSpecific), but for extension methods in polymorphic
    givens, the comparison was done with a constraint set that does not
    include the type parameters of the givens, this lead to ambiguity errors
    as experienced in
    typelevel/spotted-leopards#2.
    
    We fix this by ensuring the TyperState we use for the comparison
    contains any additional constraint specific to the TyperState of either
    alternative. This required generalizing TyperState#mergeConstraintWith
    to handle `this` not being committable (because in that case `this` does
    not need to take ownership of the type variables owned by `that`,
    therefore `that` itself is allowed to be committable).
    smarter committed Sep 11, 2021
    Configuration menu
    Copy the full SHA
    3bcd253 View commit details
    Browse the repository at this point in the history