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
Rework implicit search #3421
Commits on Nov 1, 2017
-
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.
-
Commits on Nov 3, 2017
-
Reflect nesting of lazy_implicit values in their levels
This caused nested ambiguity errors with the next commit.
-
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.
-
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.
-
Commits on Nov 5, 2017
-
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].
-
-
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.
Commits on Nov 6, 2017
-
-
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.
-
-
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.
-
-
-
Commits on Nov 7, 2017
-
-
-
Disable numeric value tie break
All tests pass, and it is unclear what this is trying to achieve.
-
Commits on Nov 8, 2017
Commits on Nov 13, 2017
-
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.
Commits on Nov 14, 2017
-
-
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.