Skip to content

Commit 3c29355

Browse files
authored
Improve documentation of implicit conversions (#20336)
2 parents 473897c + cbd8408 commit 3c29355

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

docs/_docs/reference/changed-features/implicit-conversions-spec.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ Views are applied in three situations:
4343
`v` which is applicable to `e` and whose result contains a method
4444
`m` which is applicable to `args` is searched. The search proceeds
4545
as in the case of implicit parameters, where the implicit scope is
46-
the one of `T`. If such a view is found, the application
47-
`e.m(args)` is converted to `v(e).m(args)`.
46+
the one of `T => pt`, with `pt` being the structural type
47+
`{ def m(args: T_1 , ... , T_n): U }`. If such a view is found,
48+
the application `e.m(args)` is converted to `v(e).m(args)`.
4849

4950
# Differences with Scala 2 implicit conversions
5051

docs/_spec/07-implicits.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The _parts_ of a type ´T´ are:
6363
- if ´T´ is a type projection `´S´#´U´`, the parts of ´S´ as well as ´T´ itself;
6464
- if ´T´ is a type alias, the parts of its expansion;
6565
- if ´T´ is an abstract type, the parts of its upper bound;
66-
- if ´T´ denotes an implicit conversion to a type with a method with argument types ´T_1, ..., T_n´ and result type ´U´, the union of the parts of ´T_1, ..., T_n´ and ´U´;
66+
- if ´T´ is a structural type with a method with argument types ´T_1, ..., T_n´ and result type ´U´, the union of the parts of ´T_1, ..., T_n´ and ´U´;
6767
- in all other cases, just ´T´ itself.
6868

6969
Note that packages are internally represented as classes with companion modules to hold the package members.
@@ -288,7 +288,7 @@ The search proceeds as in the case of implicit parameters, where the implicit sc
288288
If such a view is found, the selection ´e.m´ is converted to `´v´(´e´).´m´`.
289289
1. In a selection ´e.m(\mathit{args})´ with ´e´ of type ´T´, if the selector ´m´ denotes some member(s) of ´T´, but none of these members is applicable to the arguments ´\mathit{args}´.
290290
In this case a view ´v´ is searched which is applicable to ´e´ and whose result contains a method ´m´ which is applicable to ´\mathit{args}´.
291-
The search proceeds as in the case of implicit parameters, where the implicit scope is the one of ´T´. If such a view is found, the selection ´e.m´ is converted to `´v´(´e´).´m(\mathit{args})´`.
291+
The search proceeds as in the case of implicit parameters, where the implicit scope is the one of `´T´ => ´\mathit{pt}´`, with ´\mathit{pt}´ being the structural type ´{ def m(\mathit{args}: T_1 , ... , T_n): U }´. If such a view is found, the selection ´e.m´ is converted to `´v´(´e´).´m(\mathit{args})´`.
292292

293293
The implicit view, if it is found, can accept its argument ´e´ as a call-by-value or as a call-by-name parameter.
294294
However, call-by-value implicits take precedence over call-by-name implicits.

0 commit comments

Comments
 (0)