Skip to content

Fix links in docs #11389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/internals/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ semi ::= ‘;’ | nl {nl}

## Optional Braces

The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](../reference/other-new-features-indentation.html)
The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](../reference/other-new-features/indentation.md)

In the context-free productions below we use the notation `<<< ts >>>`
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
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/reference/metaprogramming/macros-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Separator * ::= '
The two environment combinators are both associative with left and
right identity `()`.

### Operational semantics:
### Operational semantics

We define a small step reduction relation `-->` with the following rules:
```
Expand All @@ -111,6 +111,7 @@ splice evaluation context `e_s` are defined syntactically as follows:
Eval context e ::= [ ] | e t | v e | 'e_s[${e}]
Splice context e_s ::= [ ] | (x: T) => e_s | e_s t | u e_s
```

### Typing rules

Typing judgments are of the form `Es |- t: T`. There are two
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Initial implementation in [PR #3464](https://github.com/lampepfl/dotty/pull/3464

## Syntax

```
```ebnf
FunArgTypes ::= InfixType
| ‘(’ [ FunArgType {',' FunArgType } ] ‘)’
| ‘(’ TypedFunParam {',' TypedFunParam } ‘)’
TypedFunParam ::= id ‘:’ Type
```

Dependent function types associate to the right, e.g.
`(s: S) (t: T) U` is the same as `(s: S) ((t: T) U)`.
`(s: S) => (t: T) => U` is the same as `(s: S) => ((t: T) => U)`.

## Implementation

Expand All @@ -25,7 +25,7 @@ refinement types of `scala.FunctionN`. A dependent function type
`(x1: K1, ..., xN: KN) => R` of arity `N` translates to:

```scala
FunctionN[K1, ..., Kn, R'] with
FunctionN[K1, ..., Kn, R']:
def apply(x1: K1, ..., xN: KN): R
```

Expand Down
28 changes: 13 additions & 15 deletions docs/docs/reference/other-new-features/transparent-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ val x = Set(if condition then Val else Var)

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:

- The type of the conditional above is the [union type](new-types/union-types.md) `Val | Var`.
- A union type is widened in type inference to the least supertype that is
not a union type. In the example, this type is `Kind & Product & Serializable` since all three traits are traits of both `Val` and `Var`.
So that type becomes the inferred element type of the set.
- The type of the conditional above is the [union type](../new-types/union-types.md) `Val | Var`.
- A union type is widened in type inference to the least supertype that is not a union type.
In the example, this type is `Kind & Product & Serializable` since all three traits are traits of both `Val` and `Var`.
So that type becomes the inferred element type of the set.

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`:

Expand All @@ -46,9 +46,8 @@ by adding a [`@transparentTrait` annotation](https://dotty.epfl.ch/api/scala/ann
Typically, transparent traits are traits
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:

- `IterableOps`, which provides method implementations for an `Iterable`
- `StrictOptimizedSeqOps`, which optimises some of these implementations for
sequences with efficient indexing.
- `IterableOps`, which provides method implementations for an `Iterable`.
- `StrictOptimizedSeqOps`, which optimises some of these implementations for sequences with efficient indexing.

Generally, any trait that is extended recursively is a good candidate to be
declared transparent.
Expand All @@ -59,13 +58,12 @@ Transparent traits can be given as explicit types as usual. But they are often e

The precise rules are as follows:

- When inferring a type of a type variable, or the type of a val, or the return type of a def,
- where that type is not higher-kinded,
- and where `B` is its known upper bound or `Any` if none exists:
- If the type inferred so far is of the form `T1 & ... & Tn` where
`n >= 1`, replace the maximal number of transparent `Ti`s by `Any`, while ensuring that
the resulting type is still a subtype of the bound `B`.
- However, do not perform this widening if all transparent traits `Ti` can get replaced in that way.
- When inferring a type of a type variable, or the type of a val, or the return type of a def,
- where that type is not higher-kinded,
- and where `B` is its known upper bound or `Any` if none exists:
- If the type inferred so far is of the form `T1 & ... & Tn` where
`n >= 1`, replace the maximal number of transparent `Ti`s by `Any`, while ensuring that
the resulting type is still a subtype of the bound `B`.
- However, do not perform this widening if all transparent traits `Ti` can get replaced in that way.

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.

2 changes: 1 addition & 1 deletion docs/docs/reference/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ semi ::= ‘;’ | nl {nl}

## Optional Braces

The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](../other-new-features/indentation.md).
The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](./other-new-features/indentation.md).

In the context-free productions below we use the notation `<<< ts >>>`
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
Expand Down