Skip to content

Commit 0f1d350

Browse files
authored
Merge pull request #11062 from michelou/scala3-docs
[docs/reference] more fixes in Markdown files
2 parents 96401b6 + cef31fb commit 0f1d350

22 files changed

+67
-61
lines changed

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ implicit val myConverter: Int => String = _.toString
8181
implicit val myConverter: Conversion[Int, String] = _.toString
8282
```
8383

84-
Note that implicit conversions are also affected by the
85-
[changes to implicit resolution](implicit-resolution.md) between Scala 2 and
86-
Scala 3.
84+
Note that implicit conversions are also affected by the [changes to implicit resolution](implicit-resolution.md) between Scala 2 and Scala 3.
8785

8886
## Motivation for the changes
8987

@@ -99,24 +97,20 @@ val x: String = 1 // Scala 2: assigns "abc" to x
9997
// Scala 3: type error
10098
```
10199

102-
This snippet contains a type error. The right hand side of `val x`
100+
This snippet contains a type error. The right-hand side of `val x`
103101
does not conform to type `String`. In Scala 2, the compiler will use
104102
`m` as an implicit conversion from `Int` to `String`, whereas Scala 3
105103
will report a type error, because `Map` isn't an instance of
106104
`Conversion`.
107105

108106
## Migration path
109107

110-
Implicit values that are used as views should see their type changed
111-
to `Conversion`.
108+
Implicit values that are used as views should see their type changed to `Conversion`.
112109

113110
For the migration of implicit conversions that are affected by the
114-
changes to implicit resolution, refer to the [Changes in Implicit
115-
Resolution](implicit-resolution.md) for more information.
111+
changes to implicit resolution, refer to the [Changes in Implicit Resolution](implicit-resolution.md) for more information.
116112

117113
## Reference
118114

119-
For more information about implicit resolution, see [Changes in
120-
Implicit Resolution](implicit-resolution.md).
121-
Other details are available in
122-
[PR #2065](https://github.com/lampepfl/dotty/pull/2065).
115+
For more information about implicit resolution, see [Changes in Implicit Resolution](implicit-resolution.md).
116+
Other details are available in [PR #2065](https://github.com/lampepfl/dotty/pull/2065).

docs/docs/reference/changed-features/numeric-literals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ BigFloat.FromDigits.fromDigits("1e100000000000")
199199
Evaluating this expression throws a `NumberTooLarge` exception at run time. We would like it to
200200
produce a compile-time error instead. We can achieve this by tweaking the `BigFloat` class
201201
with a small dose of metaprogramming. The idea is to turn the `fromDigits` method
202-
into a macro, i.e. make it an inline method with a splice as right hand side.
202+
into a macro, i.e. make it an inline method with a splice as right-hand side.
203203
To do this, replace the `FromDigits` instance in the `BigFloat` object by the following two definitions:
204204

205205
```scala

docs/docs/reference/changed-features/overload-resolution.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ as follows:
4040
resolution yields several competing alternatives when `n >= 1` parameter lists are taken
4141
into account, then resolution re-tried using `n + 1` argument lists.
4242

43-
This change is motivated by the new language feature [extension
44-
methods](../contextual/extension-methods.md), where emerges the need to do
43+
This change is motivated by the new language feature
44+
[extension methods](../contextual/extension-methods.md), where emerges the need to do
4545
overload resolution based on additional argument blocks.
4646

4747
## Parameter Types of Function Values
@@ -51,12 +51,14 @@ pass such values in the first argument list of an overloaded application, provid
5151
that the remaining parameters suffice for picking a variant of the overloaded function.
5252
For example, the following code compiles in Scala 3, while it results in an
5353
missing parameter type error in Scala2:
54+
5455
```scala
5556
def f(x: Int, f2: Int => Int) = f2(x)
5657
def f(x: String, f2: String => String) = f2(x)
5758
f("a", _.toUpperCase)
5859
f(2, _ * 2)
5960
```
61+
6062
To make this work, the rules for overloading resolution in [SLS §6.26.3](https://www.scala-lang.org/files/archive/spec/2.13/06-expressions.html#overloading-resolution) are modified
6163
as follows:
6264

@@ -75,11 +77,15 @@ is determined as followed:
7577
- Otherwise the known type of `E` is the result of typing `E` with an undefined expected type.
7678

7779
A pattern matching closure
80+
7881
```scala
7982
{ case P1 => B1 ... case P_n => B_n }
8083
````
84+
8185
is treated as if it was expanded to the function value
86+
8287
```scala
8388
x => x match { case P1 => B1 ... case P_n => B_n }
8489
```
90+
8591
and is therefore also approximated with a `? => ?` type.

docs/docs/reference/changed-features/pattern-bindings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ From Scala 3.1 on, type checking rules will be tightened so that warnings are re
1313
```scala
1414
val xs: List[Any] = List(1, 2, 3)
1515
val (x: String) :: _ = xs // error: pattern's type String is more specialized
16-
// than the right hand side expression's type Any
16+
// than the right-hand side expression's type Any
1717
```
1818
This code gives a compile-time warning in Scala 3.1 (and also in Scala 3.0 under the `-source 3.1` setting) whereas it will fail at runtime with a `ClassCastException` in Scala 2. In Scala 3.1, a pattern binding is only allowed if the pattern is _irrefutable_, that is, if the right-hand side's type conforms to the pattern's type. For instance, the following is OK:
1919
```scala
@@ -38,7 +38,7 @@ Analogous changes apply to patterns in `for` expressions. For instance:
3838
```scala
3939
val elems: List[Any] = List((1, 2), "hello", (3, 4))
4040
for (x, y) <- elems yield (y, x) // error: pattern's type (Any, Any) is more specialized
41-
// than the right hand side expression's type Any
41+
// than the right-hand side expression's type Any
4242
```
4343
This code gives a compile-time warning in Scala 3.1 whereas in Scala 2 the list `elems`
4444
is filtered to retain only the elements of tuple type that match the pattern `(x, y)`.

docs/docs/reference/changed-features/pattern-matching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ precedence over _product-sequence match_.
8787
A usage of a variadic extractor is irrefutable if one of the following conditions holds:
8888

8989
- the extractor is used directly as a sequence match or product-sequence match
90-
- `U = Some[T]` (for Scala2 compatibility)
90+
- `U = Some[T]` (for Scala 2 compatibility)
9191
- `U <: R` and `U <: { def isEmpty: false }`
9292

9393
## Boolean Match

docs/docs/reference/contextual/context-functions-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ new scala.ContextFunctionN[T1, ..., Tn, T]:
5353

5454
A context parameter may also be a wildcard represented by an underscore `_`. In that case, a fresh name for the parameter is chosen arbitrarily.
5555

56-
Note: The closing paragraph of the
56+
**Note:** The closing paragraph of the
5757
[Anonymous Functions section](https://www.scala-lang.org/files/archive/spec/2.13/06-expressions.html#anonymous-functions)
5858
of Scala 2.13 is subsumed by context function types and should be removed.
5959

docs/docs/reference/contextual/derivation.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ inline def derived[A](using gen: K0.Generic[A]) as Eq[A] =
326326
The framework described here enables all three of these approaches without mandating any of them.
327327

328328
For a brief discussion on how to use macros to write a type class `derived`
329-
method please read more at [How to write a type class `derived` method using
330-
macros](./derivation-macro.md).
329+
method please read more at [How to write a type class `derived` method using macros](./derivation-macro.md).
331330

332331
### Deriving instances elsewhere
333332

@@ -353,7 +352,7 @@ ConstrApps ::= ConstrApp {‘with’ ConstrApp}
353352
| ConstrApp {‘,’ ConstrApp}
354353
```
355354

356-
Note: To align `extends` clauses and `derives` clauses, Scala 3 also allows multiple
355+
**Note:** To align `extends` clauses and `derives` clauses, Scala 3 also allows multiple
357356
extended types to be separated by commas. So the following is now legal:
358357

359358
```scala

docs/docs/reference/contextual/givens.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ a given for the type `Ord[Int]` whereas `listOrd[T]` defines givens
3333
for `Ord[List[T]]` for all types `T` that come with a given instance for `Ord[T]`
3434
themselves. The `using` clause in `listOrd` defines a condition: There must be a
3535
given of type `Ord[T]` for a given of type `Ord[List[T]]` to exist.
36-
Such conditions are expanded by the compiler to [context
37-
parameters](./using-clauses.md).
36+
Such conditions are expanded by the compiler to [context parameters](./using-clauses.md).
3837

3938
## Anonymous Givens
4039

@@ -98,7 +97,7 @@ transparent inline given mkAnnotations[A, T]: Annotations[A, T] = ${
9897
}
9998
```
10099

101-
Since `mkAnnotations` is `transparent`, the type of an application is the type of its right hand side, which can be a proper subtype of the declared result type `Annotations[A, T]`.
100+
Since `mkAnnotations` is `transparent`, the type of an application is the type of its right-hand side, which can be a proper subtype of the declared result type `Annotations[A, T]`.
102101

103102
## Pattern-Bound Given Instances
104103

@@ -167,5 +166,5 @@ of given instances:
167166

168167
- A _structural instance_ contains one or more types or constructor applications,
169168
followed by `with` and a template body that contains member definitions of the instance.
170-
- An _alias instance_ contains a type, followed by `=` and a right hand side expression.
169+
- An _alias instance_ contains a type, followed by `=` and a right-hand side expression.
171170
- An _abstract instance_ contains just the type, which is not followed by anything.

docs/docs/reference/contextual/multiversal-equality.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This definition effectively says that values of type `T` can (only) be
4343
compared to other values of type `T` when using `==` or `!=`. The definition
4444
affects type checking but it has no significance for runtime
4545
behavior, since `==` always maps to `equals` and `!=` always maps to
46-
the negation of `equals`. The right hand side `CanEqual.derived` of the definition
46+
the negation of `equals`. The right-hand side `CanEqual.derived` of the definition
4747
is a value that has any `CanEqual` instance as its type. Here is the definition of class
4848
`CanEqual` and its companion object:
4949

docs/docs/reference/contextual/relationship-implicits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Given instances can be mapped to combinations of implicit objects, classes and i
3838
```
3939

4040
3. Alias givens map to implicit methods or implicit lazy vals. If an alias has neither type nor context parameters,
41-
it is treated as a lazy val, unless the right hand side is a simple reference, in which case we can use a forwarder to
41+
it is treated as a lazy val, unless the right-hand side is a simple reference, in which case we can use a forwarder to
4242
that reference without caching it.
4343

4444
Examples:

0 commit comments

Comments
 (0)