Skip to content

Commit 6c55ed8

Browse files
authored
Merge pull request #1284 from Kordyjan/scala-3.1.0
3.1 release blogpost
2 parents abcf8f5 + 48b9ece commit 6c55ed8

File tree

4 files changed

+197
-3
lines changed

4 files changed

+197
-3
lines changed

_downloads/2021-10-18-3.1.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Scala 3.1.0
3+
start: 18 October 2021
4+
layout: downloadpage
5+
release_version: 3.1.0
6+
release_date: "October 18, 2021"
7+
permalink: /download/3.1.0.html
8+
license: <a href="https://www.scala-lang.org/license/">Apache License, Version 2.0</a>
9+
---
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
layout: blog-detail
3+
post-type: blog
4+
by: Paweł Marks, VirtusLab
5+
title: Scala 3.1.0 released!
6+
---
7+
8+
Hello from the Scala 3 team! It has already been six weeks since we have announced the release candidate for the first minor version after the initial release of Scala 3. Now, after two more RCs, we can confidently promote Scala 3.1.0-RC3 to a new stable release of the language. In other words, Scala 3.1.0 is officially out!
9+
10+
## Compatibility notice
11+
12+
Scala 3 follows `major.minor.patch` versioning scheme (unlike Scala 2, which uses `epoch.major.minor`). This means that this is the first *minor* release after Scala 3.0.0. This has the following consequences:
13+
14+
- Scala 3.1 is backward binary compatible: you can use dependencies compiled with Scala 3.0 in 3.1 projects.
15+
- Scala 3.1 is _not_ forward binary compatible: you _cannot_ use dependencies compiled with Scala 3.1 in Scala 3.0 projects.
16+
17+
Although we cannot guarantee full source compatibility between minor versions, we have put a lot of effort into assuring that all code that was working in 3.0.2, except in some rare cases, will also work in 3.1.0. This means that if you are an application developer, you can confidently update the compiler version to take advantage of the newest improvements. You will still be able to use dependencies compiled with Scala 3.0.
18+
19+
If you are a library maintainer, *updating to 3.1.0 will force all of your users to update to 3.1.0 as well*. We understand that the current state of binary compatibility may be unsatisfactory. We are actively working on technical solutions to support forward-compatibility in 3.2.0. In the meantime, we recommend testing your library with Scala 3.1.0 and 3.0.2, but _publishing_ it with 3.0.2. This will allow downstream users to use your library even if they can’t update to Scala 3.1.0. You can find an example of build that follows this recommendation [here](https://github.com/typelevel/scalacheck/pull/847).
20+
21+
## What's new in 3.1
22+
23+
### New experimental feature: safer exceptions
24+
25+
A new experimental feature that allows declaring and checking which exceptions can be thrown. It relies on the effects as implicit capabilities pattern.
26+
27+
You can opt-in using the following import.
28+
29+
```scala
30+
import language.experimental.saferExceptions
31+
```
32+
33+
Now it is possible to mark types with the type of exception that can be thrown during the evaluation:
34+
35+
```scala
36+
def f(x: Double): Double throws LimitExceeded =
37+
if x < limit then f(x) else throw LimitExceeded()
38+
```
39+
40+
You can read more in [the document proposing this feature](https://github.com/lampepfl/dotty/blob/release-3.1.0/docs/docs/reference/experimental/canthrow.md).
41+
42+
### Efficient bytecode for matching over strings
43+
44+
Scala, since 3.0.0, has been able to optimize pattern matches with `Int` as a scrutinee type by emitting bytecode containing very efficient instructions: `lookupswitch` or `tableswitch`.
45+
Now in Scala 3.1, similar behavior was implemented for matching over `String` literals.
46+
47+
```scala
48+
fruit match
49+
case "apple" => 1
50+
case "orange" => 2
51+
case "banana" => 3
52+
case _ => 0
53+
```
54+
55+
will now generate `lookupswitch` over hash codes of `String` literals instead of a chain of conditional expressions. This behavior is consistent with what Java does and more performant than the old approach.
56+
57+
### Support for `-Wconf` and `@nowarn`
58+
59+
We have added a `-Wconf` compiler flag that allows filtering and configuring compiler warnings (silence them, or turn them into errors).
60+
61+
We have also brought back `@nowarn` annotation from Scala 2.13, originally inspired by [the silencer plugin](https://github.com/ghik/silencer). It can be used for suppressing warnings directly in the code, in the places where they are expected to occur.
62+
63+
`-Wconf` and `@nowarn` work largely the same way as in Scala 2, but some filters for selecting warnings are different. For the more details see the output of `-Wconf:help` flag.
64+
65+
### Simplified Manifest synthesis
66+
67+
For the sake of compatibility with Scala 2, the Scala 3 compiler now generates given instances for the `Manifest` trait. The new implementation is a slightly simplified approximation of the Scala 2 implementation. It guarantees that any of the expressions:
68+
69+
- `manifest[A] == manifest[B]`
70+
- `manifest[A].runtimeClass == manifest[B].runtimeClass`
71+
- `optManifest[A] == optManifest[B]`
72+
- `optManifest[A].asInstanceOf[ClassTag[A]].runtimeClass == optManifest[B].asInstanceOf[ClassTag[B]].runtimeClass`
73+
74+
that were true in Scala 2, will also remain true when compiled with Scala 3.
75+
76+
### Mirrors for Hierarchical Sealed Types
77+
78+
Consider the following sealed hierarchy:
79+
80+
```scala
81+
sealed trait Top
82+
case class Middle() extends Top with Bottom
83+
sealed trait Bottom extends Top
84+
```
85+
86+
Previously you would not be able to summon an instance of `scala.deriving.Mirror.SumOf` for `Top`, as its child `Bottom` is not a case class. In Scala 3.1 this is now possible, enabling compiletime reflection over nested hierarchies of sealed types.
87+
88+
The only change necessary for users is that they should now consider that one of the `MirroredElemTypes` for a `Mirror.SumOf` could also be a sum type, not just product types.
89+
90+
### Other changes
91+
92+
- Scastie was integrated into Scaladoc to make snippets interactive.
93+
- `@experimental` annotation is no longer itself experimental. The users are no longer required to use a nightly build of the compiler to be able to define experimental APIs. See more detail in [the design document](https://github.com/lampepfl/dotty/blob/release-3.1.0/docs/docs/reference/other-new-features/experimental-defs.md)
94+
- Now `TastyInspector.{inspectTastyFiles, inspectTastyFilesInJar, inspectAllTastyFiles}` return a boolean value indicating whether the process succeeded
95+
- A `Wildcard` was made a subtype of `Ident` in the reflection API
96+
- `TypedOrTest` was added as a supertype of `Typed` in the reflection API
97+
- `Unapply.apply` was added to allow contruction of `Unapply` trees from macros
98+
- Unreductible match types now raise type errors
99+
- Scala 3.1 targets Scala.js 1.7.x+. This means that users must upgrade to Scala.js 1.7.0 or later to use Scala 3.1.
100+
101+
Beside that Scala 3.1.0 introduced multiple small improvements and fixed a handful of bugs. You can see [the detailed changelog](https://github.com/lampepfl/dotty/releases/tag/3.1.0) on GitHub.
102+
103+
## What's next
104+
105+
During the Scala 3.1.0 stabilization period, which took the last six weeks, we haven't stopped improving the language and fixing the bugs in the compiler. You can already test the results of our work, using the published release candidate: Scala 3.1.1-RC1. [The full changelog](https://github.com/lampepfl/dotty/releases/tag/3.1.1-RC1) is as always available on GitHub.
106+
107+
You can expect the stable release of Scala 3.1.1 in early December.
108+
109+
## Contributors
110+
111+
Thank you to all the contributors who made the release of 3.1.0 possible 🎉
112+
113+
According to `git shortlog -sn --no-merges 3.0.2..3.1.0` these are:
114+
115+
```
116+
61 Martin Odersky
117+
51 tanishiking
118+
50 Nicolas Stucki
119+
39 Kacper Korban
120+
33 Andrzej Ratajczak
121+
22 Dale Wijnand
122+
22 Olivier Blanvillain
123+
21 Lukas Rytz
124+
17 Filip Zybała
125+
16 Yichen Xu
126+
15 Rikito Taniguchi
127+
14 Sébastien Doeraene
128+
12 Krzysztof Romanowski
129+
11 EnzeXing
130+
9 Guillaume Martres
131+
9 Jamie Thompson
132+
8 Tom Grigg
133+
6 Seth Tisue
134+
5 Alec Theriault
135+
4 Michał Pałka
136+
4 Phil
137+
3 Fengyun Liu
138+
3 Paweł Marks
139+
2 Vadim Chelyshov
140+
2 Dmitrii Naumenko
141+
2 Julien Richard-Foy
142+
2 Kevin Lee
143+
2 Liu Fengyun
144+
2 Stéphane Micheloud
145+
2 Tomasz Godzik
146+
2 Adrien Piquerez
147+
2 adampauls
148+
2 noti0na1
149+
1 Kai
150+
1 Jeremy Smith
151+
1 Som Snytt
152+
1 Anselm von Wangenheim
153+
1 Boris
154+
1 Arnout Engelen
155+
1 odersky
156+
1 Anatolii Kmetiuk
157+
1 PJ Fanning
158+
1 Matthieu Bovel
159+
1 Performant Data
160+
1 Mario Bucev
161+
1 Ruslan Shevchenko
162+
```
163+
164+
## Library authors: Join our community build
165+
166+
Scala 3 has a set of widely-used community libraries that are built against every nightly Scala 3 snapshot.
167+
Join our [community build](https://github.com/lampepfl/dotty/tree/master/community-build)
168+
to make sure that our regression suite includes your library.
169+
170+
[Scastie]: https://scastie.scala-lang.org/?target=dotty
171+
172+
[@odersky]: https://github.com/odersky
173+
[@DarkDimius]: https://github.com/DarkDimius
174+
[@smarter]: https://github.com/smarter
175+
[@felixmulder]: https://github.com/felixmulder
176+
[@nicolasstucki]: https://github.com/nicolasstucki
177+
[@liufengyun]: https://github.com/liufengyun
178+
[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain
179+
[@biboudis]: https://github.com/biboudis
180+
[@allanrenucci]: https://github.com/allanrenucci
181+
[@Blaisorblade]: https://github.com/Blaisorblade
182+
[@Duhemm]: https://github.com/Duhemm
183+
[@AleksanderBG]: https://github.com/AleksanderBG
184+
[@milessabin]: https://github.com/milessabin
185+
[@anatoliykmetyuk]: https://github.com/anatoliykmetyuk

download/scala3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: downloadpage
33
title: Download Scala 3
44

5-
release_version: 3.0.2
6-
release_date: "September 1, 2021"
5+
release_version: 3.1.0
6+
release_date: "October 18, 2021"
77
license: <a href="https://www.scala-lang.org/license/">Apache License, Version 2.0</a>
88
---

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ headerButtonUrl: "/what-is-scala/"
99

1010
# Links of the Download / API Docs sections
1111
gettingStarted:
12-
mainTitle: "Scala 3.0.2"
12+
mainTitle: "Scala 3.1.0"
1313
mainUrl: "/download/scala3.html"
1414
subtitle: "Documentation"
1515
subtitleLink: "https://docs.scala-lang.org/scala3"

0 commit comments

Comments
 (0)