Skip to content

Commit c0ce202

Browse files
committed
Add doc page for language versions
1 parent e566c74 commit c0ce202

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

docs/docs/usage/language-versions.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
layout: doc-page
3+
title: "Language Versions"
4+
---
5+
6+
The default Scala language version currently supported by the Dotty compiler is `3.0`. There are also other language versions that can be specified instead:
7+
8+
- `3.1`: A preview of changes introduced in the next version after 3.0. Some Scala-2 specific idioms will be dropped in this version. The feature set supported by this version will be refined over time as we approach its release.
9+
10+
- `3.0-migration`: Same as `3.0` but with a Scala 2 compatibility mode that helps moving Scala 2.13 sources over to Scala 3. In particular, it
11+
12+
- flags some Scala 2 constructs that are disallowed in Scala 3 as migration warnings instead of hard errors,
13+
- changes some rules to be more lenient and backwards compatible with Scala 2.13
14+
- gives some additional warnings where the semantics has changed between Scala 2.13 and 3.0
15+
- in conjunction with `-rewrite`, offer code rewrites from Scala 2.13 to 3.0.
16+
17+
- `3.1-migration: Same as `3.1` but with additional helps to migrate from `3.0`. The helpers are similar to, but less extensive than, the ones for `3.0-migration`.
18+
19+
There are two ways to specify a language version.
20+
21+
- With a `-source` command line setting, e.g. `-source 3.0-migration`.
22+
- With a `scala.language` import at the top of a compilation unit, e.g:
23+
24+
```scala
25+
package p
26+
import scala.language.`3.1`
27+
28+
class C { ... }
29+
```
30+
31+
Language imports supersede command-line settings in the compilation units where they are specified. Only one language import is allowed in a compilation unit, and it must come before any definitions in that unit.

docs/sidebar.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ sidebar:
1111
url: docs/usage/ide-support.html
1212
- title: Worksheet mode in Dotty IDE
1313
url: docs/usage/worksheet-mode.html
14+
- title: Language Versions
15+
url: docs/usage/language-versions.html
1416
- title: cbt-projects
1517
url: docs/usage/cbt-projects.html
1618
- title: Dottydoc

0 commit comments

Comments
 (0)