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/internals/syntax.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ semi ::= ‘;’ | nl {nl}
88
88
89
89
## Optional Braces
90
90
91
-
The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](../reference/other-new-features-indentation.html)
91
+
The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](../reference/other-new-features/indentation.md)
92
92
93
93
In the context-free productions below we use the notation `<<< ts >>>`
94
94
to indicate a token sequence `ts` that is either enclosed in a pair of braces `{ ts }` or that constitutes an indented region `indent ts outdent`. Analogously, the
Copy file name to clipboardExpand all lines: docs/docs/reference/other-new-features/transparent-traits.md
+13-15Lines changed: 13 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,10 @@ val x = Set(if condition then Val else Var)
19
19
20
20
Here, the inferred type of `x` is `Set[Kind & Product & Serializable]` whereas one would have hoped it to be `Set[Kind]`. The reasoning for this particular type to be inferred is as follows:
21
21
22
-
- The type of the conditional above is the [union type](new-types/union-types.md)`Val | Var`.
23
-
- A union type is widened in type inference to the least supertype that is
24
-
not a union type. In the example, this type is `Kind & Product & Serializable` since all three traits are traits of both `Val` and `Var`.
25
-
So that type becomes the inferred element type of the set.
22
+
- The type of the conditional above is the [union type](../new-types/union-types.md)`Val | Var`.
23
+
- A union type is widened in type inference to the least supertype that is not a union type.
24
+
In the example, this type is `Kind & Product & Serializable` since all three traits are traits of both `Val` and `Var`.
25
+
So that type becomes the inferred element type of the set.
26
26
27
27
Scala 3 allows one to mark a mixin trait as `transparent`, which means that it can be suppressed in type inference. Here's an example that follows the lines of the code above, but now with a new transparent trait `S` instead of `Product`:
28
28
@@ -46,9 +46,8 @@ by adding a [`@transparentTrait` annotation](https://dotty.epfl.ch/api/scala/ann
46
46
Typically, transparent traits are traits
47
47
that influence the implementation of inheriting classes and traits that are not usually used as types by themselves. Two examples from the standard collection library are:
48
48
49
-
-`IterableOps`, which provides method implementations for an `Iterable`
50
-
-`StrictOptimizedSeqOps`, which optimises some of these implementations for
51
-
sequences with efficient indexing.
49
+
-`IterableOps`, which provides method implementations for an `Iterable`.
50
+
-`StrictOptimizedSeqOps`, which optimises some of these implementations for sequences with efficient indexing.
52
51
53
52
Generally, any trait that is extended recursively is a good candidate to be
54
53
declared transparent.
@@ -59,13 +58,12 @@ Transparent traits can be given as explicit types as usual. But they are often e
59
58
60
59
The precise rules are as follows:
61
60
62
-
- When inferring a type of a type variable, or the type of a val, or the return type of a def,
63
-
- where that type is not higher-kinded,
64
-
- and where `B` is its known upper bound or `Any` if none exists:
65
-
- If the type inferred so far is of the form `T1 & ... & Tn` where
66
-
`n >= 1`, replace the maximal number of transparent `Ti`s by `Any`, while ensuring that
67
-
the resulting type is still a subtype of the bound `B`.
68
-
- However, do not perform this widening if all transparent traits `Ti` can get replaced in that way.
61
+
- When inferring a type of a type variable, or the type of a val, or the return type of a def,
62
+
- where that type is not higher-kinded,
63
+
- and where `B` is its known upper bound or `Any` if none exists:
64
+
- If the type inferred so far is of the form `T1 & ... & Tn` where
65
+
`n >= 1`, replace the maximal number of transparent `Ti`s by `Any`, while ensuring that
66
+
the resulting type is still a subtype of the bound `B`.
67
+
- However, do not perform this widening if all transparent traits `Ti` can get replaced in that way.
69
68
70
69
The last clause ensures that a single transparent trait instance such as `Product` is not widened to `Any`. Transparent trait instances are only dropped when they appear in conjunction with some other type.
Copy file name to clipboardExpand all lines: docs/docs/reference/syntax.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,7 @@ semi ::= ‘;’ | nl {nl}
87
87
88
88
## Optional Braces
89
89
90
-
The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](../other-new-features/indentation.md).
90
+
The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](./other-new-features/indentation.md).
91
91
92
92
In the context-free productions below we use the notation `<<< ts >>>`
93
93
to indicate a token sequence `ts` that is either enclosed in a pair of braces `{ ts }` or that constitutes an indented region `indent ts outdent`. Analogously, the
0 commit comments