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

Rework implicit search #3421

Merged
merged 30 commits into from Nov 15, 2017
Merged

Rework implicit search #3421

merged 30 commits into from Nov 15, 2017

Commits on Nov 1, 2017

  1. Fix scala#3396: Abort implicit search if result does not match

    Don't proceed with implicit search if result type cannot match - the search
    will likely by under-constrained, which means that an unbounded number of alternatives
    is tried. See strawman-contrib MapDecoratorTest.scala for an example where this happens.
    odersky committed Nov 1, 2017
    Copy the full SHA
    fd7ba2b View commit details
    Browse the repository at this point in the history
  2. Fix typo in comment

    odersky committed Nov 1, 2017
    Copy the full SHA
    fd70c61 View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2017

  1. Reflect nesting of lazy_implicit values in their levels

    This caused nested ambiguity errors with the next commit.
    odersky committed Nov 3, 2017
    Copy the full SHA
    2d4efa0 View commit details
    Browse the repository at this point in the history
  2. Propagate implicit ambiguity and divergence failures

    Propagate implicit ambiguity and divergence failures from implicit arguments
    to their callers. In particular, and ambiguity in an implicit argument means
    that the whole implicit search is ambiguous. Previously, the local ambiguity
    translated to an "implicit not found" on the next outer level, which meant that
    another implicit on that level could qualify and the ambiguity would be
    forgotten.
    
    The code is still a bit rough and could profit from some refactorings.
    odersky committed Nov 3, 2017
    Copy the full SHA
    d7c8604 View commit details
    Browse the repository at this point in the history
  3. Move iterator-from test to pending

    This is a temporary fix. iterator-from seems to cause
    non-deterministic ambiguity errors. Moving to pending until
    we have figured out what goes wrong.
    odersky committed Nov 3, 2017
    Copy the full SHA
    c311bf3 View commit details
    Browse the repository at this point in the history
  4. Add test

    odersky committed Nov 3, 2017
    Copy the full SHA
    beb90b4 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    c1c9198 View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2017

  1. The great implicits re-org

    Refactoring of implicits with the aim of clearer code and better error
    messages. Here's an example:
    
        -- Error: implicitSearch.scala:15:12 -------------------------------------------
        15 |    sort(xs)  // error (with a partially constructed implicit argument shown)
           |            ^
           |no implicit argument of type Test.Ord[scala.collection.immutable.List[scala.collection.immutable.List[T]]] was found for parameter o of method sort in object Test.
           |I found:
           |
           |    Test.listOrd[T](Test.listOrd[T](/* missing */implicitly[Test.Ord[T]]))
           |
           |But no implicit values were found that match type Test.Ord[T].
    odersky committed Nov 5, 2017
    Copy the full SHA
    a32b4b8 View commit details
    Browse the repository at this point in the history
  2. Add @sharable to global data

    odersky committed Nov 5, 2017
    Copy the full SHA
    e1cf2c9 View commit details
    Browse the repository at this point in the history
  3. Disable refined preference scheme for implicits

    Turns out it's not transitive when combined with the old scheme. So it
    should be one or the other. Conservatively, this commit reverts to the old
    scheme.
    odersky committed Nov 5, 2017
    Copy the full SHA
    7da033b View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2017

  1. Copy the full SHA
    e6ffe35 View commit details
    Browse the repository at this point in the history
  2. Replace isAsGood with ternary operator

    The aim is to have ultimately fewer comparisons. The downside is
    that some of the comparisons are now more expensive, because types
    have to be compared where they previously weren't.
    odersky committed Nov 6, 2017
    Copy the full SHA
    d06d5ae View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    d8028de View commit details
    Browse the repository at this point in the history
  4. New scheme for handling implicits

     - Merge `rankImplicits` and `condense` into one phase
     - Fix handling of ambiguities - the previous unconditional
       abort was wrong, because another alternative might be
       better than both ambiguous choices.
    odersky committed Nov 6, 2017
    Copy the full SHA
    2270899 View commit details
    Browse the repository at this point in the history
  5. Cleanups

    odersky committed Nov 6, 2017
    Copy the full SHA
    01d8dfb View commit details
    Browse the repository at this point in the history
  6. Fix doc comment

    odersky committed Nov 6, 2017
    Copy the full SHA
    83f86ab View commit details
    Browse the repository at this point in the history
  7. Fix test comment

    odersky committed Nov 6, 2017
    Copy the full SHA
    2df8031 View commit details
    Browse the repository at this point in the history
  8. Remove stray text in comment

    odersky committed Nov 6, 2017
    Copy the full SHA
    50bf462 View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2017

  1. Copy the full SHA
    ebb4ba2 View commit details
    Browse the repository at this point in the history
  2. Add some doc comments

    odersky committed Nov 7, 2017
    Copy the full SHA
    15744fb View commit details
    Browse the repository at this point in the history
  3. Disable numeric value tie break

    All tests pass, and it is unclear what this is trying to achieve.
    odersky committed Nov 7, 2017
    Copy the full SHA
    0e8a74d View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    9c1d942 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2017

  1. Copy the full SHA
    0bae8a3 View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2017

  1. Implement negation of implicit searches

    Previously, ambiguous implicits were used to make a local implicit
    search fail so that another alternative could be considered globally.
    This is no longer possible because implicit search now propagates.
    
    This commit makes similar functionality available by implementing
    a special Not class. It also re-establishes the old behavior under
    -language:Scala2, issuing a migration warning.
    odersky committed Nov 13, 2017
    Copy the full SHA
    2144367 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2017

  1. Copy the full SHA
    03779a1 View commit details
    Browse the repository at this point in the history
  2. Fix handling divergent implicits

    If we hit a divergent implicit during a contextual search, we should
    continue with a type-based search. Only ambiguities are globally fatal.
    The removed test that prevented this logic was introduced when I experimented
    with fatal divergence. It was left in by oversight.
    odersky committed Nov 14, 2017
    Copy the full SHA
    98c4b7d View commit details
    Browse the repository at this point in the history

Commits on Nov 15, 2017

  1. Address reviewers comments

    odersky committed Nov 15, 2017
    Copy the full SHA
    39b4ec2 View commit details
    Browse the repository at this point in the history
  2. Fix typo

    odersky committed Nov 15, 2017
    Copy the full SHA
    66b0d9a View commit details
    Browse the repository at this point in the history
  3. Avoid infinite loop

    odersky committed Nov 15, 2017
    Copy the full SHA
    0da21e1 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    db1b09a View commit details
    Browse the repository at this point in the history