Skip to content

Commit b1a0234

Browse files
committed
Update doc on implicit resolution changes
Update doc on implicit resolution changes to take the previous changes in #5887 into account.
1 parent 0802f47 commit b1a0234

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

docs/docs/reference/changed-features/implicit-resolution.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,26 @@ affect implicits on the language level.
3535

3636
This will now resolve the `implicitly` call to `j`, because `j` is nested
3737
more deeply than `i`. Previously, this would have resulted in an
38-
ambiguity error.
38+
ambiguity error. The previous possibility of an implicit search failure
39+
due to _shadowing_ (where an implicit is hidden by a nested definition)
40+
no longer applies.
3941

40-
3. The treatment of ambiguity errors has changed. If an ambiguity is encountered
42+
3. Package prefixes no longer contribute to the implicit scope of a type.
43+
Example:
44+
45+
package p
46+
implied a for A
47+
48+
object o {
49+
implied b for B
50+
type C
51+
}
52+
53+
Both `a` and `b` are visible as implicits at the point of the definition
54+
of `type C`. However, a reference to `p.o.C` outside of package `p` will
55+
have only `b` in its implicit scope but not `a`.
56+
57+
4. The treatment of ambiguity errors has changed. If an ambiguity is encountered
4158
in some recursive step of an implicit search, the ambiguity is propagated to the caller.
4259
Example: Say you have the following definitions:
4360

@@ -65,14 +82,14 @@ affect implicits on the language level.
6582
which implements negation directly. For any query type `Q`: `Not[Q]` succeeds if and only if
6683
the implicit search for `Q` fails.
6784

68-
4. The treatment of divergence errors has also changed. A divergent implicit is
85+
5. The treatment of divergence errors has also changed. A divergent implicit is
6986
treated as a normal failure, after which alternatives are still tried. This also makes
7087
sense: Encountering a divergent implicit means that we assume that no finite
7188
solution can be found on the given path, but another path can still be tried. By contrast
7289
most (but not all) divergence errors in Scala 2 would terminate the implicit
7390
search as a whole.
7491

75-
5. Scala-2 gives a lower level of priority to implicit conversions with call-by-name
92+
6. Scala-2 gives a lower level of priority to implicit conversions with call-by-name
7693
parameters relative to implicit conversions with call-by-value parameters. Dotty
7794
drops this distinction. So the following code snippet would be ambiguous in Dotty:
7895

@@ -81,7 +98,7 @@ affect implicits on the language level.
8198
def buzz(y: A) = ???
8299
buzz(1) // error: ambiguous
83100

84-
6. The rule for picking a _most specific_ alternative among a set of overloaded or implicit
101+
7. The rule for picking a _most specific_ alternative among a set of overloaded or implicit
85102
alternatives is refined to take the number of inferable parameters into account. All else
86103
being equal, an alternative that takes more inferable parameters is taken to be more specific
87104
than an alternative that takes fewer. The following paragraph in the SLS is affected by this change:

0 commit comments

Comments
 (0)