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/implicit-by-name-parameters.md
+11-4Lines changed: 11 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -33,21 +33,28 @@ The precise steps for constructing an implicit argument for a by-name parameter
33
33
34
34
1. Create a new implicit value with a fresh name _lv_, which has the signature of the following definition:
35
35
36
-
implicit lazy val lv: T
36
+
```scala
37
+
implicitlazyvallv:T
38
+
```
37
39
38
40
The current implementation uses the prefix `$lazy_implicit$` followed by a unique integer for _lv_.
39
41
40
42
1. Thislazyvalis not immediately available ascandidateforimplicit search (making it immediately available would result in a looping implicit computation). But it becomes available in all nested contexts that look again for an implicit argument to a by-name parameter.
41
43
42
44
1. Ifthisimplicit search succeeds with expression `E`, and `E` contains references to the lazyimplicit value _lv_, replace `E` by
43
45
44
-
{ implicit lazy val lv: T = E; lv }
46
+
47
+
```scala
48
+
{ implicitlazyvallv:T=E; lv }
49
+
```
45
50
46
51
Otherwise, return `E` unchanged.
47
52
48
53
In the example above, the definition of `s` would be expanded asfollows.
49
54
50
-
val s = implicitly[Test.Serializable[Option[Int]]](
51
-
serializeOption[Int](serializeInt))
55
+
```scala
56
+
vals= implicitly[Test.Serializable[Option[Int]]](
57
+
serializeOption[Int](serializeInt))
58
+
```
52
59
53
60
No lazy val was generated because the synthesized argument is not recursive.
0 commit comments