Skip to content

Commit 3a7a6ae

Browse files
authored
Merge pull request #10767 from michelou/scala3-docs
[docs/reference] fixed many issues in MarkDown files
2 parents e8d748e + 6fbc7e5 commit 3a7a6ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+182
-162
lines changed

docs/docs/reference/changed-features/compiler-plugins.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class DivideZero extends StandardPlugin {
6666
val name: String = "divideZero"
6767
override val description: String = "divide zero check"
6868

69-
def init(options: List[String]): List[PluginPhase] = (new DivideZeroPhase) :: Nil
69+
def init(options: List[String]): List[PluginPhase] =
70+
(new DivideZeroPhase) :: Nil
7071
}
7172

7273
class DivideZeroPhase extends PluginPhase {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ where the type may still be inferred:
2424
...
2525
}
2626
```
27-
**2.** Nesting is now taken into account for selecting an implicit.Consider for instance the following scenario:
27+
**2.** Nesting is now taken into account for selecting an implicit. Consider for instance the following scenario:
2828
```scala
2929
def f(implicit i: C) = {
3030
def g(implicit j: C) = {
@@ -55,7 +55,7 @@ have only `b` in its implicit search scope but not `a`.
5555
In more detail, here are the rules for what constitutes the implicit scope of
5656
a type:
5757

58-
**Definition:** A reference is an _anchor_ if it refers to an object, a class, a trait, an abstract type, an opaque type alias, or a match type alias. References to packages and package objects are anchors only under -source:3.0-migration.
58+
**Definition:** A reference is an _anchor_ if it refers to an object, a class, a trait, an abstract type, an opaque type alias, or a match type alias. References to packages and package objects are anchors only under `-source:3.0-migration`.
5959

6060
**Definition:** The _anchors_ of a type _T_ is a set of references defined as follows:
6161

@@ -122,7 +122,7 @@ most (but not all) divergence errors in Scala 2 would terminate the implicit sea
122122
def buzz(y: A) = ???
123123
buzz(1) // error: ambiguous
124124
```
125-
**7.** The rule for picking a _most specific_ alternative among a set of overloaded or implicit alternatives is refined to take context parameters into account. All else being equal, an alternative that takes some context parameters is taken to be less specific than an alternative that takes none. If both alternatives take context parameters, we try to choose between them as if they were methods with regular parameters. The following paragraph in the SLS is affected by this change:
125+
**7.** The rule for picking a _most specific_ alternative among a set of overloaded or implicit alternatives is refined to take context parameters into account. All else being equal, an alternative that takes some context parameters is taken to be less specific than an alternative that takes none. If both alternatives take context parameters, we try to choose between them as if they were methods with regular parameters. The following paragraph in the [SLS §6.26.3](https://scala-lang.org/files/archive/spec/2.13/06-expressions.html#overloading-resolution) is affected by this change:
126126

127127
_Original version:_
128128

docs/docs/reference/changed-features/interpolation-escapes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: doc-page
33
title: Escapes in interpolations
44
---
55

6-
In Scala 2 there was no straightforward way to represent a single quote character `"` in a single quoted interpolation. A \ character can't be used for that because interpolators themselves decide how to handle escaping, so the parser doesn't know whether the " should be escaped or used as a terminator.
6+
In Scala 2 there was no straightforward way to represent a single quote character `"` in a single quoted interpolation. A `\` character can't be used for that because interpolators themselves decide how to handle escaping, so the parser doesn't know whether the `"` should be escaped or used as a terminator.
77

88
In Dotty, you can use the `$` meta character of interpolations to escape a `"` character.
99

docs/docs/reference/changed-features/match-syntax.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The syntactical precedence of match expressions has been changed.
1616
case "empty" => 0
1717
case "nonempty" => 1
1818
}
19+
```
1920

2021
2. `match` may follow a period:
2122

@@ -26,6 +27,7 @@ The syntactical precedence of match expressions has been changed.
2627
}
2728
then "nonempty"
2829
else "empty"
30+
```
2931

3032
3. The scrutinee of a match expression must be an `InfixExpr`. Previously the scrutinee could be followed by a type ascription `: T`, but this is no longer supported. So `x : T match { ... }` now has to be
3133
written `(x: T) match { ... }`.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ numbers that can have both a decimal point and an exponent:
7979
```scala
8080
object FromDigits {
8181

82-
/** A subclass of `FromDigits` that also allows to convert whole number literals
83-
* with a radix other than 10
82+
/** A subclass of `FromDigits` that also allows to convert whole
83+
* number literals with a radix other than 10
8484
*/
8585
trait WithRadix[T] extends FromDigits[T] {
8686
def fromDigits(digits: String): T = fromDigits(digits, 10)

docs/docs/reference/changed-features/operators.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ one of the following conditions holds:
4747
- the operator is followed by an opening brace.
4848

4949
An alphanumeric operator is an operator consisting entirely of letters, digits, the `$` and `_` characters, or
50-
any unicode character `c` for which `java.lang.Character.isIdentifierPart(c)` returns `true`.
50+
any Unicode character `c` for which `java.lang.Character.isIdentifierPart(c)` returns `true`.
5151

5252
Infix operations involving symbolic operators are always allowed, so `infix` is redundant for methods with symbolic names.
5353

@@ -89,9 +89,9 @@ The purpose of the `infix` modifier is to achieve consistency across a code base
8989
5. To smooth migration to Scala 3.0, alphanumeric operators will only be deprecated from Scala 3.1 onwards,
9090
or if the `-source 3.1` option is given in Dotty/Scala 3.
9191

92-
## The @targetName Annotation
92+
## The `@targetName` Annotation
9393

94-
It is recommended that definitions of symbolic operators carry a [@targetName annotation](../other-new-features/targetName.html) that provides an encoding of the operator with an alphanumeric name. This has several benefits:
94+
It is recommended that definitions of symbolic operators carry a [`@targetName` annotation](../other-new-features/targetName.md) that provides an encoding of the operator with an alphanumeric name. This has several benefits:
9595

9696
- It helps interoperability between Scala and other languages. One can call
9797
a Scala-defined symbolic operator from another language using its target name,
@@ -115,7 +115,7 @@ def condition =
115115
|| xs.exists(_ > 0)
116116
|| xs.isEmpty
117117
```
118-
Previously, these expressions would have been rejected, since the compiler's semicolon inference
118+
Previously, those expressions would have been rejected, since the compiler's semicolon inference
119119
would have treated the continuations `++ " world"` or `|| xs.isEmpty` as separate statements.
120120

121121
To make this syntax work, the rules are modified to not infer semicolons in front of leading infix operators.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ are in the first argument list.
1313

1414
Overloading resolution now can take argument lists into account when
1515
choosing among a set of overloaded alternatives.
16-
For example, the following code compiles in Dotty, while it results in an
17-
ambiguous overload error in Scala2:
16+
For example, the following code compiles in Scala 3, while it results in an
17+
ambiguous overload error in Scala 2:
1818

1919
```scala
2020
def f(x: Int)(y: String): Int = 0
@@ -33,7 +33,7 @@ g(2)(3)(4) // ok
3333
g(2)(3)("") // ok
3434
```
3535

36-
To make this work, the rules for overloading resolution in section 6.23.3 of the SLS are augmented
36+
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 augmented
3737
as follows:
3838

3939
> In a situation where a function is applied to more than one argument list, if overloading
@@ -57,7 +57,7 @@ def f(x: String, f2: String => String) = f2(x)
5757
f("a", _.toUpperCase)
5858
f(2, _ * 2)
5959
```
60-
To make this work, the rules for overloading resolution in section 6.23.3 of the SLS are modified
60+
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
6161
as follows:
6262

6363
Replace the sentence

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ want to decompose it like this:
2525
```scala
2626
val first :: rest = elems // error
2727
```
28-
This works in Scala 2. In fact it is a typical use case for Scala 2's rules. But in Scala 3.1 it will give a type error. One can avoid the error by marking the pattern with an @unchecked annotation:
28+
This works in Scala 2. In fact it is a typical use case for Scala 2's rules. But in Scala 3.1 it will give a type error. One can avoid the error by marking the pattern with an `@unchecked` annotation:
2929
```scala
3030
val first :: rest : @unchecked = elems // OK
3131
```
3232
This will make the compiler accept the pattern binding. It might give an error at runtime instead, if the underlying assumption that `elems` can never be empty is wrong.
3333

34-
## Pattern Bindings in For Expressions
34+
## Pattern Bindings in `for` Expressions
3535

3636
Analogous changes apply to patterns in `for` expressions. For instance:
3737

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ layout: doc-page
33
title: "Option-less pattern matching"
44
---
55

6-
Dotty implementation of pattern matching was greatly simplified compared to scalac. From a user perspective, this means that Dotty generated patterns are a *lot* easier to debug, as variables all show up in debug modes and positions are correctly preserved.
6+
Dotty implementation of pattern matching was greatly simplified compared to Scala 2. From a user perspective, this means that Scala 3 generated patterns are a *lot* easier to debug, as variables all show up in debug modes and positions are correctly preserved.
77

8-
Dotty supports a superset of scalac's [extractors](https://www.scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#extractor-patterns).
8+
Dotty supports a superset of Scala 2 [extractors](https://www.scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#extractor-patterns).
99

1010
## Extractors
1111

@@ -54,7 +54,7 @@ A usage of a fixed-arity extractor is irrefutable if one of the following condit
5454

5555
- `U = true`
5656
- the extractor is used as a product match
57-
- `U = Some[T]` (for Scala2 compatibility)
57+
- `U = Some[T]` (for Scala 2 compatibility)
5858
- `U <: R` and `U <: { def isEmpty: false }`
5959

6060
### Variadic Extractors
@@ -84,7 +84,7 @@ and `S` conforms to one of the two matches above.
8484
The former form of `unapplySeq` has higher priority, and _sequence match_ has higher
8585
precedence over _product-sequence match_.
8686

87-
A usage of a variadic extractor is irrefutable if one of the following condition holds:
87+
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
9090
- `U = Some[T]` (for Scala2 compatibility)
@@ -230,7 +230,8 @@ object CharList {
230230
```Scala
231231
class Foo(val name: String, val children: Int *)
232232
object Foo {
233-
def unapplySeq(f: Foo): Option[(String, Seq[Int])] = Some((f.name, f.children))
233+
def unapplySeq(f: Foo): Option[(String, Seq[Int])] =
234+
Some((f.name, f.children))
234235
}
235236

236237
def foo(f: Foo) = f match {

docs/docs/reference/changed-features/structural-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Here's an example of a structural type `Person`:
4242
val age: Int
4343
}
4444
```
45-
The person type adds a _refinement_ to its parent type `Record` that defines `name` and `age` fields. We say the refinement is _structural_ since `name` and `age` are not defined in the parent type. But they exist nevertheless as members of class `Person`. For instance, the following
45+
The type `Person` adds a _refinement_ to its parent type `Record` that defines the two fields `name` and `age`. We say the refinement is _structural_ since `name` and `age` are not defined in the parent type. But they exist nevertheless as members of class `Person`. For instance, the following
4646
program would print "Emma is 42 years old.":
4747
```scala
4848
val person = Record("name" -> "Emma", "age" -> 42).asInstanceOf[Person]

0 commit comments

Comments
 (0)