You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_docs/reference/changed-features/implicit-resolution.md
-23Lines changed: 0 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,26 +164,3 @@ The new rules are as follows: An implicit `a` defined in `A` is more specific th
164
164
Condition (*) is new. It is necessary to ensure that the defined relation is transitive.
165
165
166
166
[//]: # todo: expand with precise rules
167
-
168
-
**9.** Implicit resolution now tries to avoid recursive givens that can lead to an infinite loop at runtime. Here is an example:
169
-
170
-
```scala
171
-
objectPrices {
172
-
opaquetypePrice=BigDecimal
173
-
174
-
objectPrice{
175
-
givenOrdering[Price] = summon[Ordering[BigDecimal]] // was error, now avoided
176
-
}
177
-
}
178
-
```
179
-
180
-
Previously, implicit resolution would resolve the `summon` to the given in `Price`, leading to an infinite loop (a warning was issued in that case). We now use the underlying given in `BigDecimal` instead. We achieve that by adding the following rule for implicit search:
181
-
182
-
- When doing an implicit search while checking the implementation of a `given` definition `G`, discard all search results that lead back to `G` or to a given
183
-
with the same owner as `G` that comes later in the source than `G`.
184
-
185
-
The new behavior is enabled under `-source future`. In earlier versions, a
186
-
warning is issued where that behavior will change.
187
-
188
-
Old-style implicit definitions are unaffected by this change.
Implicit resolution now avoids generating recursive givens that can lead to an infinite loop at runtime. Here is an example:
9
+
10
+
```scala
11
+
objectPrices {
12
+
opaquetypePrice=BigDecimal
13
+
14
+
objectPrice{
15
+
givenOrdering[Price] = summon[Ordering[BigDecimal]] // was error, now avoided
16
+
}
17
+
}
18
+
```
19
+
20
+
Previously, implicit resolution would resolve the `summon` to the given in `Price`, leading to an infinite loop (a warning was issued in that case). We now use the underlying given in `BigDecimal` instead. We achieve that by adding the following rule for implicit search:
21
+
22
+
- When doing an implicit search while checking the implementation of a `given` definition `G` of the form
23
+
```
24
+
given ... = ....
25
+
```
26
+
discard all search results that lead back to `G` or to a given with the same owner as `G` that comes later in the source than `G`.
27
+
28
+
The new behavior is enabled with the `experimental.givenLoopPrevention` language import. If no such import or setting is given, a warning is issued where the behavior would change under that import (for source version 3.4 and later).
29
+
30
+
Old-style implicit definitions are unaffected by this change.
0 commit comments