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
+20-1Lines changed: 20 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -163,8 +163,27 @@ The new rules are as follows: An implicit `a` defined in `A` is more specific th
163
163
164
164
Condition (*) is new. It is necessary to ensure that the defined relation is transitive.
165
165
166
+
[//]: # todo: expand with precise rules
166
167
168
+
**9.** Implicit resolution now tries to avoid recursive givens that can lead to an infinite loop at runtime. Here is an example:
167
169
170
+
```scala
171
+
objectPrices {
172
+
opaquetypePrice=BigDecimal
168
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.
0 commit comments