@@ -35,9 +35,26 @@ affect implicits on the language level.
35
35
36
36
This will now resolve the ` implicitly ` call to ` j ` , because ` j ` is nested
37
37
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.
39
41
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
41
58
in some recursive step of an implicit search, the ambiguity is propagated to the caller.
42
59
Example: Say you have the following definitions:
43
60
@@ -65,14 +82,14 @@ affect implicits on the language level.
65
82
which implements negation directly. For any query type ` Q ` : ` Not[Q] ` succeeds if and only if
66
83
the implicit search for ` Q ` fails.
67
84
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
69
86
treated as a normal failure, after which alternatives are still tried. This also makes
70
87
sense: Encountering a divergent implicit means that we assume that no finite
71
88
solution can be found on the given path, but another path can still be tried. By contrast
72
89
most (but not all) divergence errors in Scala 2 would terminate the implicit
73
90
search as a whole.
74
91
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
76
93
parameters relative to implicit conversions with call-by-value parameters. Dotty
77
94
drops this distinction. So the following code snippet would be ambiguous in Dotty:
78
95
@@ -81,7 +98,7 @@ affect implicits on the language level.
81
98
def buzz(y: A) = ???
82
99
buzz(1) // error: ambiguous
83
100
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
85
102
alternatives is refined to take the number of inferable parameters into account. All else
86
103
being equal, an alternative that takes more inferable parameters is taken to be more specific
87
104
than an alternative that takes fewer. The following paragraph in the SLS is affected by this change:
0 commit comments