Skip to content

Commit 977a62e

Browse files
authored
Sync with the stable documentation branch (#16483)
This pull request is syncing the main with changes from language-reference-stable. It was created automatically after 29639f9 by @WojciechMazur
2 parents da50d11 + 80b2841 commit 977a62e

File tree

112 files changed

+2785
-1348
lines changed

Some content is hidden

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

112 files changed

+2785
-1348
lines changed

.github/workflows/ci.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Dotty
22

33
on:
44
push:
5-
branches-ignore:
6-
- 'language-reference-stable'
75
tags:
86
- '**'
97
pull_request:

docs/_assets/css/frontpage.css

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ h1#main {
2828
/* navigation */
2929
header {
3030
font-size: 24px;
31+
margin-block-end: calc(2* var(--base-spacing));
3132
}
3233

3334
header .nav-item i {

docs/_assets/docsScalaLangResources/scaladoc-assets.html

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: index
3+
title: Procedures
4+
---
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: index
3+
title: IDEs and Tools
4+
---

docs/_docs/internals/gadts.md

+26-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# GADTs - Broad overview
1+
---
2+
layout: doc-page
3+
title: "GADTs - Broad overview"
4+
---
5+
6+
## Introduction
27

38
There are multiple levels to the implementation. They deal with slightly different problems. The most important levels are the following ones:
49

@@ -18,9 +23,9 @@ There are also other parts to supporting GADTs. Roughly in order of importance,
1823
1. Attachment key is named `inferredGadtConstraints`.
1924
4. When we select members on a type that may have GADT constraints, we perform special "healing" by approximating the type using those constraints. We cannot take the constraints into account because member lookup is cached, and GADT constraints are only valid for specific scopes.
2025

21-
# Useful widgets
26+
## Useful widgets
2227

23-
## Expr
28+
### Expr
2429

2530
This is the classical GADT example:
2631

@@ -36,7 +41,7 @@ enum Expr[T] {
3641
}
3742
```
3843

39-
## EQ
44+
### EQ
4045

4146
The following enum will result in an equality constraint between `S` and `T` if we match on it:
4247

@@ -46,7 +51,7 @@ enum EQ[S, T] {
4651
}
4752
```
4853

49-
## SUB
54+
### SUB
5055

5156
The following enum will result in a subtyping constraint `S <: T` if we match on it:
5257

@@ -56,9 +61,9 @@ enum SUB[-S, +T] {
5661
}
5762
```
5863

59-
# Details of above
64+
## Details of above
6065

61-
## What abstract types can have GADT constraints
66+
### What abstract types can have GADT constraints
6267

6368
Right now, we record GADT constraints for:
6469

@@ -67,9 +72,9 @@ Right now, we record GADT constraints for:
6772

6873
There is a branch on the way which will also record them for type members (so path-dependent types) and singleton types. It has a paper associated: "Implementing path-depepdent GADTs for Scala 3".
6974

70-
## What are necessary relationships? Any examples?
75+
### What are necessary relationships? Any examples?
7176

72-
### Covariance means no constraint is necessary
77+
#### Covariance means no constraint is necessary
7378

7479
Standard (non-case) classes allow "strange" inheritance which means that we cannot infer any information from covariant type parameters.
7580

@@ -90,7 +95,7 @@ class Weird(list: List[String]) extends IntList with Expr[Nothing]
9095

9196
Case classes have a special check which disallows inheritance like `Weird`. This means we can infer extra information from them.
9297

93-
## Breaking down the constraints
98+
### Breaking down the constraints
9499

95100
```scala
96101
class Expr[A]
@@ -113,9 +118,9 @@ def foo[T](e: Expr[List[T]]): T =
113118
}
114119
```
115120

116-
## Relation betweeen GadtConstraint and OrderingConstraint
121+
### Relation betweeen GadtConstraint and OrderingConstraint
117122

118-
### Internal and external types
123+
#### Internal and external types
119124

120125
GadtConstraint uses OrderingConstraint as the datastructure to record information about GADT constraints.
121126

@@ -127,9 +132,9 @@ To solve this, GadtConstraint internally creates TypeParamRefs which it adds to
127132

128133
The TypeParamRefs and TypeVars registered in one constraint cannot ever be present in types mentioned in the other type constraint. The internal TypeParamRefs and TypeVars cannot ever leak out of the GadtConstraint. We cannot ever record a bound in GadtConstraint which mentions TypeParamRefs used for type inference. (That part is ensured by the way TypeComparer is organised &#x2013; we will always try to record bounds in the "normal" constraint before recording a GADT bound.)
129134

130-
# Other details
135+
## Other details
131136

132-
## TypeComparer approximations
137+
### TypeComparer approximations
133138

134139
TypeComparer sometimes approximates the types it compares. Let's see an example based on these definitions:
135140

@@ -142,11 +147,11 @@ when comparing if `IntList <: Expr[Int]`, `TypeComparer` will approximate `IntLi
142147

143148
The variables which TypeComparer sets are `approxState` and `frozenGadt`.
144149

145-
## Necessary/sufficient either
150+
### Necessary/sufficient either
146151

147152
TypeComparer sometimes needs to approximate some constraints, specifically when dealing with intersection and union types. The way this approximation works changes if we're currently inferring GADT constraints. This is hopefully documented well in TypeComparer in doc comments for `necessaryEither` and `sufficientEither`.
148153

149-
## Types bound in patterns
154+
### Types bound in patterns
150155

151156
```scala
152157
(list : List[Int]) match {
@@ -161,7 +166,7 @@ TypeComparer sometimes needs to approximate some constraints, specifically when
161166
}
162167
```
163168

164-
## Internal structure of OrderingConstraint
169+
### Internal structure of OrderingConstraint
165170

166171
Imagine we have two type parameters in scope, `A` and `B`.
167172

@@ -184,19 +189,19 @@ B <: A
184189

185190
The first two constraints are "entries" &#x2013; they are easy to look up whenever we ask for bounds of `A` or `B`. The third constraint is an ordering &#x2013; it helps with correctly propagating the bounds we record.
186191

187-
# Possible broad improvements
192+
## Possible broad improvements
188193

189-
## Allow OrderingConstraint to record bounds for things other than TypeParamRefs
194+
### Allow OrderingConstraint to record bounds for things other than TypeParamRefs
190195

191196
This would mean we no longer need to keep the bidirectional mapping in GadtConstraint.
192197

193-
## Not mixing OrderingConstraint and ConstraintHandling in GadtConstraint
198+
### Not mixing OrderingConstraint and ConstraintHandling in GadtConstraint
194199

195200
GadtConstraint right now mixes OrderingConstraint and ConstraintHandling. The first one is supposed to be the immutable constraint datastructure. The second one implements mutable functionality around a variable containing the immutable datastructure.
196201

197202
GadtConstraint mixes them both. Things would be better organised if GadtConstraint was split like the normal constraint.
198203

199-
## Creating a separate TypeComparer for breaking down types into GADT constraints
204+
### Creating a separate TypeComparer for breaking down types into GADT constraints
200205

201206
TypeComparer is biased towards one specific way of approximating constraints. When we infer types, it's ok to be "optimistic". When inferring GADT constraints, we should be as pessimistic as possible, in order to only infer constraints which are necessary.
202207

docs/_docs/reference/contextual/derivation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Note the following properties of `Mirror` types,
284284
+ The methods `ordinal` and `fromProduct` are defined in terms of `MirroredMonoType` which is the type of kind-`*`
285285
which is obtained from `MirroredType` by wildcarding its type parameters.
286286

287-
### Implementing `derived` with `Mirror`
287+
## Implementing `derived` with `Mirror`
288288

289289
As seen before, the signature and implementation of a `derived` method for a type class `TC[_]` are arbitrary, but we expect it to typically be of the following form:
290290

@@ -484,7 +484,7 @@ The framework described here enables all three of these approaches without manda
484484
For a brief discussion on how to use macros to write a type class `derived`
485485
method please read more at [How to write a type class `derived` method using macros](./derivation-macro.md).
486486

487-
### Syntax
487+
## Syntax
488488

489489
```
490490
Template ::= InheritClauses [TemplateBody]

docs/_docs/reference/other-new-features/opaques.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,6 @@ val z = l2(3.1)
174174
l1.mul(x, y) // type checks
175175
l1.mul(x, z) // error: found l2.Logarithm, required l1.Logarithm
176176
```
177-
In general, one can think of an opaque type as being only transparent in the scope of `private[this]`.
177+
In general, one can think of an opaque type as being only transparent in the scope of `private[this]` (unless the type is a top level definition - in this case, it's transparent only within the file it's defined in).
178178

179179
[More details](opaques-details.md)

docs/_layouts/doc-page.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
<main>
66
<header>
77
{% if urls.editSource %}
8-
<a class="text-button with-link body-small" href="{{ urls.editSource }}">
9-
Edit this page on GitHub
10-
</a>
8+
<a class="text-button with-link body-small" href="{{ urls.editSource }}">Edit this page on GitHub</a>
119
{% endif %}
1210
<h1 class="h600">{{ page.title }}</h1>
1311
</header>

docs/_layouts/index.html

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
---
22
layout: static-site-main
33
---
4-
<h1>{{ page.title }}</h1>
5-
6-
{{ content }}
7-
8-
<h2>Table of Contents</h2>
9-
<ul class="table-of-contents">
10-
{% for subpage in site.subpages %}
11-
<li>
12-
<a href="{{ subpage.url }}">{{ subpage.title }}</a>
13-
</li>
14-
{% endfor %}
15-
</ul>
4+
5+
<main>
6+
<header>
7+
{% if urls.editSource %}
8+
<!--<a class="text-button with-link body-small" href="{{ urls.editSource }}">Edit this page on GitHub</a>-->
9+
{% endif %}
10+
<h1 class="h600">{{ page.title }}</h1>
11+
</header>
12+
13+
{{ content }}
14+
15+
<h2 class="h500">Table of Contents</h2>
16+
<ul class="table-of-contents">
17+
{% for subpage in site.subpages %}
18+
<li>
19+
<a href="{{ subpage.url }}">{{ subpage.title }}</a>
20+
</li>
21+
{% endfor %}
22+
</ul>
23+
24+
</main>

docs/_layouts/main.html

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
---
22
layout: base
3-
extraJS:
4-
- js/contributors.js
5-
extraCSS:
6-
- css/content-contributors.css
73
---
84

95
<div id="content-wrapper">{{ content }}</div>

docs/_layouts/static-site-main.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
<div id="site-header"></div>
77
{% if page.nightlyOf %}
88
<aside class="warning">
9+
<div class='icon'></div>
10+
<div class='content'>
911
This is a nightly documentation. The content of this page may not be
1012
consistent with the current stable version of language. Click
1113
<a href="{{ page.nightlyOf }}">here</a> to find the stable version of this
1214
page.
15+
</div>
1316
</aside>
1417
{% endif %} {{ content }}
1518
<div class="divider" />
@@ -28,7 +31,7 @@
2831
</div>
2932
{% endif %} {% if page.next %}
3033
<div>
31-
<span class="body-small">Next</span>
34+
<span class="body-small arrow-navigation--next">Next</span>
3235
<a
3336
rel="next"
3437
href="{{ page.next.url }}"

docs/sidebar.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ subsection:
5656
- page: reference/metaprogramming/macros-spec.md
5757
hidden: true
5858
- page: reference/metaprogramming/simple-smp.md # description of a simplified metaprogramming language, this might not be the best place for it
59-
hidden: true
6059
- page: reference/metaprogramming/staging.md
6160
- page: reference/metaprogramming/reflection.md
6261
- page: reference/metaprogramming/tasty-inspect.md
@@ -174,11 +173,13 @@ subsection:
174173
- page: contributing/debugging.md
175174
- title: IDEs and Tools
176175
directory: tools
176+
index: contributing/tools/index.md
177177
subsection:
178178
- page: contributing/tools/ide.md
179179
- page: contributing/tools/mill.md
180180
- page: contributing/tools/scalafix.md
181181
- title: Procedures
182+
index: contributing/procedures/index.md
182183
subsection:
183184
- page: contributing/procedures/release.md
184185
- page: contributing/procedures/vulpix.md

project/DocumentationWebsite.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object DocumentationWebsite {
1414

1515

1616
val contributorsTestcasesDestinationFile = Paths.get("scaladoc-testcases", "docs", "_assets", "js", "contributors.js").toFile
17-
val contributorsDestinationFile = Paths.get("docs", "_assets", "js", "contributors.js").toFile
17+
val contributorsDestinationFile = baseDest / "dotty_res" / "scripts" / "contributors.js"
1818
sbt.IO.copyFile(contributorsFile, contributorsTestcasesDestinationFile)
1919
sbt.IO.copyFile(contributorsFile, contributorsDestinationFile)
2020

@@ -25,8 +25,8 @@ object DocumentationWebsite {
2525
val cssCodeSnippetsSourceFile = cssSourceFileBase / "code-snippets.css"
2626
sbt.IO.copyFile(cssCodeSnippetsSourceFile, cssCodeSnippetsDesitnationFile)
2727

28-
val cssContentContributorsTestcasesDesitnationFile = Paths.get("docs", "_assets", "css", "content-contributors.css").toFile
29-
val cssContentContributorsDesitnationFile = Paths.get("scaladoc-testcases", "docs", "_assets", "css", "content-contributors.css").toFile
28+
val cssContentContributorsTestcasesDesitnationFile = Paths.get("scaladoc-testcases", "docs", "_assets", "css", "content-contributors.css").toFile
29+
val cssContentContributorsDesitnationFile = baseDest / "dotty_res" / "styles" / "content-contributors.css"
3030
val cssContentContributorsSourceFile = cssContentContributorsSourceBaseFile / "content-contributors.css"
3131
sbt.IO.copyFile(cssContentContributorsSourceFile, cssContentContributorsTestcasesDesitnationFile)
3232
sbt.IO.copyFile(cssContentContributorsSourceFile, cssContentContributorsDesitnationFile)

project/resources/referenceReplacements/_layouts/static-site-main.html

-11
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,4 @@
2323
</div>
2424
{% endif %}
2525
</nav>
26-
<div class="content-contributors hidden">
27-
<h1 class="h200">Contributors to this page</h1>
28-
<div id="documentation-contributors" class="contributors-container"></div>
29-
{% if urls.editSource %}
30-
<div class="github-edit-button">
31-
<a class="text-button with-link body-small" href="{{ urls.editSource }}">
32-
Edit this page on GitHub
33-
</a>
34-
</div>
35-
{% endif %}
36-
</div>
3726
</div>

project/scripts/check-cla.sh

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
set -eux
33

44
echo "Pull request submitted by $AUTHOR";
5-
signed=$(curl -s https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR | jq -r ".signed");
6-
if [ "$signed" = "true" ] ; then
5+
if [ "$AUTHOR" = "github-actions[bot]" ] ; then
76
echo "CLA check for $AUTHOR successful";
87
else
9-
echo "CLA check for $AUTHOR failed";
10-
echo "Please sign the Scala CLA to contribute to the Scala compiler.";
11-
echo "Go to https://www.lightbend.com/contribute/cla/scala and then";
12-
echo "comment on the pull request to ask for a new check.";
13-
echo "";
14-
echo "Check if CLA is signed: https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR";
15-
exit 1;
8+
signed=$(curl -s "https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR" | jq -r ".signed");
9+
if [ "$signed" = "true" ] ; then
10+
echo "CLA check for $AUTHOR successful";
11+
else
12+
echo "CLA check for $AUTHOR failed";
13+
echo "Please sign the Scala CLA to contribute to the Scala compiler.";
14+
echo "Go to https://www.lightbend.com/contribute/cla/scala and then";
15+
echo "comment on the pull request to ask for a new check.";
16+
echo "";
17+
echo "Check if CLA is signed: https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR";
18+
exit 1;
19+
fi;
1620
fi;

project/scripts/expected-links/reference-expected-links.txt

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
./contextual/type-classes.html
4141
./contextual/using-clauses.html
4242
./docs/reference/other-new-features/named-typeargs.html
43-
./docsScalaLangResources/scaladoc-assets.html
4443
./dropped-features.html
4544
./dropped-features/auto-apply.html
4645
./dropped-features/class-shadowing-spec.html

scaladoc-js/common/src/code-snippets/CodeSnippets.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,7 @@ class CodeSnippets:
147147
)
148148
}
149149

150-
enrichSnippets()
150+
window.addEventListener("dynamicPageLoad", (e: Event) => {
151+
enrichSnippets()
152+
})
151153

0 commit comments

Comments
 (0)