Skip to content

Commit dbc4a0f

Browse files
authored
Merge pull request #1277 from Kordyjan/scala-3.0.2
Scala 3.0.2
2 parents a225298 + d7e8ebe commit dbc4a0f

File tree

4 files changed

+206
-3
lines changed

4 files changed

+206
-3
lines changed

_downloads/2021-09-01-3.0.2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Scala 3.0.2
3+
start: 1 September 2021
4+
layout: downloadpage
5+
release_version: 3.0.2
6+
release_date: "September 1, 2021"
7+
permalink: /download/3.0.2.html
8+
license: <a href="https://www.scala-lang.org/license/">Apache License, Version 2.0</a>
9+
---
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
---
2+
layout: blog-detail
3+
post-type: blog
4+
by: Paweł Marks, VirtusLab
5+
title: Scala 3.0.2 released!
6+
---
7+
8+
Greetings from the Scala 3 team! We are glad to announce that Scala 3.0.2 is now officially out. As no critical bugs have been found in the previously released Scala 3.0.2-RC2, it has been promoted to 3.0.2 and is the current stable Scala version.
9+
Recently, we are more and more confident that we can release stable versions of the compiler frequently and regularly. So, we have decided that the blog posts should focus more on stable features available for all users in the latest release of scala. So here, as a refresher, you have a summary of the most significant changes introduced in 3.0.2.
10+
11+
## What's new in 3.0.2
12+
13+
### Improved insertion of semicolons in logical conditions
14+
15+
Scala 3's indentation based syntax is aimed at making your code more concise and readable. As it gets broader adoption, we consistently improve its specification to eliminate corner cases which might lead to ambiguities or counterintuitive behaviours.
16+
17+
Thanks to [#12801](https://github.com/lampepfl/dotty/pull/12801) it is now allowed for a logical expression in an `if` statement or expression to continue in the following line if it starts in the same line as the `if` keyword, e.g.
18+
19+
```scala
20+
if foo
21+
(bar)
22+
then //...
23+
```
24+
25+
can now be used instead of
26+
27+
```scala
28+
if foo(bar)
29+
then //...
30+
```
31+
32+
If your intention is to have a block of code evaluating into a single condition you should add a new line and indentation directly after `if`, e.g.
33+
34+
```scala
35+
if
36+
val cond = foo(bar)
37+
cond
38+
then //...
39+
```
40+
41+
so code like below would NOT be valid
42+
43+
```scala
44+
if val cond = foo(bar)
45+
cond
46+
then //...
47+
```
48+
49+
### Towards better null safety in the type system
50+
51+
The compiler option `-Yexplicit-nulls` modifies Scala's standard type hierarchy to allow easier tracing of nullable values by performing strict checks directly on the level of the type system rather than just relying on conventions (e.g. this prevents you from writing code like `val foo: Option[String] = Some(null)`, which would be otherwise valid Scala although very likely to cause a `NullPointerException` at some further point).
52+
53+
After the recently introduced changes with this option enabled the `Null` type becomes a subtype of `Matchable` instead of inheriting directly from `Any`, making the code below compile (this used to compile before only without strict nullability checking).
54+
55+
```scala
56+
def foo(x: Matchable) = x match { case null => () }
57+
```
58+
59+
### Method search by type signature
60+
61+
You can now browse the documentation of Scala's API not only by names of methods but also by their type in a [Hoogle](https://hoogle.haskell.org)-like manner (but with Scala syntax) thanks to integration with [Inkuire](https://github.com/VirtusLab/Inkuire) brought up by [#12375](https://github.com/lampepfl/dotty/pull/12375).
62+
63+
To find methods with the desired signature simply write in scaladoc's searchbar the type you would expect them to have after eta-expansion (as if they were functions rather than methods).
64+
65+
![image url "image Title"](https://user-images.githubusercontent.com/39772805/117478350-53f12a80-af5f-11eb-82ab-930ba565dacb.gif)
66+
67+
### Typing escape hatch for structural types
68+
69+
Structural types may come in handy in many situations, e.g. when one wants to achieve a compromise between safety of static typing and ease of use when dealing with dynamically changing schemas of domain data structures. They have however some limitations. Among others structural typing doesn't normally play well with method overloading because some types of reflective dispatch algorithms (inlcuding JVM reflection) might not be able to choose the overloaded method alternative with the right signature without knowing upfront the exact types of the parameters after erasure. Consider the following snippet.
70+
71+
```scala
72+
class Sink[A] { def put(x: A): Unit = {} }
73+
val a = Sink[String]()
74+
val b: { def put(x: String): Unit } = a
75+
```
76+
77+
This code won't compile. This is because when `Sink[String]` gets erased to `Sink[Object]` (as it's seen from JVM's perspective) the method's signature becomes `put(x: Object): Unit` while for the structural type it remains unchanged as `put(x: String): Unit` and they wouldn't match in runtime therefore `Sink[String]` cannot be treated as a subtype of `{ def put(x: String): Unit }`.
78+
79+
We might however try to write a better method dispatch algorithm ourselves instead of relying on the JVM's default one to make this work. To assure the compiler that we know what we're doing we'll need to use the new `Selectable.WithoutPreciseParameterTypes` marker trait. Currently it's an experimental feature (introduced by [#12268](https://github.com/lampepfl/dotty/pull/12268)) so you'll be able to use it only with a snapshot or nightly version of the compiler and you'll need to annotate all subtypes of this trait with `@experimental`.
80+
81+
```scala
82+
import annotation.experimental
83+
84+
@experimental trait MultiMethodSelectable extends Selectable.WithoutPreciseParameterTypes:
85+
// smartly choose the right method implementation to call
86+
def applyDynamic(name: String, paramTypes: Class[_]*)(args: Any*): Any = ???
87+
88+
@experimental class Sink[A] extends MultiMethodSelectable:
89+
def put(x: A): Unit = {}
90+
91+
val a = new Sink[String]
92+
val b: MultiMethodSelectable { def put(x: String): Unit } = a
93+
```
94+
95+
This snippet will compile as the compiler won't perform the precise signature check for `b` anymore.
96+
97+
[More details](https://dotty.epfl.ch/docs/reference/changed-features/structural-types-spec.html#limitations-of-structural-types)
98+
99+
### Other changes
100+
101+
Beside that scala 3.0.2 introduced multiple small improvements, mainly in metaprogramming, and fixed handful of bugs. You can see [the detailed changelog](https://github.com/lampepfl/dotty/releases/tag/3.0.2) on GitHub.
102+
103+
## What's next
104+
105+
We have decided that it is the right time for the first minor version after the initial release of Scala 3. Together with stable version 3.0.2, we have released the first release candidate for Scala 3.1. You can already use 3.1.0-RC1 and test not only the new experimental features like safer exceptions but also Scastie embedded in Scaladoc pages, improvements in JVM bytecode generation, the possibility to configure the compiler warnings and lots of smaller improvements and fixes all across the board.
106+
You can find [the full changelog for 3.1.0-RC1](https://github.com/lampepfl/dotty/releases/tag/3.1.0-RC1) on GitHub.
107+
108+
You can expect the stable release of Scala 3.1 in the middle of October.
109+
110+
## Contributors
111+
112+
Thank you to all the contributors who made the release of 3.0.2 possible 🎉
113+
114+
According to `git shortlog -sn --no-merges 3.0.1..3.0.2` these are:
115+
116+
```
117+
94 Martin Odersky
118+
60 Liu Fengyun
119+
47 Kacper Korban
120+
28 Filip Zybała
121+
18 Andrzej Ratajczak
122+
17 Guillaume Martres
123+
15 Jamie Thompson
124+
10 bjornregnell
125+
9 tanishiking
126+
8 Dylan Halperin
127+
8 Anatolii Kmetiuk
128+
8 Tom Grigg
129+
7 Paweł Marks
130+
5 Som Snytt
131+
5 changvvb
132+
5 Michał Pałka
133+
5 Krzysztof Romanowski
134+
4 Aleksander Boruch-Gruszecki
135+
4 Sébastien Doeraene
136+
4 Nicolas Stucki
137+
3 Phil
138+
3 Magnolia.K
139+
2 xuwei-k
140+
2 Ben Plommer
141+
2 Florian Schmaus
142+
2 Lukas Rytz
143+
2 Maciej Gorywoda
144+
2 Markus Sutter
145+
2 Roman Kotelnikov
146+
2 Stéphane Micheloud
147+
2 noti0na1
148+
2 vincenzobaz
149+
1 Ondrej Lhotak
150+
1 KazuyaMiayshita
151+
1 odersky
152+
1 Julian Mendez
153+
1 Anton Sviridov
154+
1 GavinRay97
155+
1 EnzeXing
156+
1 Tomas Mikula
157+
1 Tomasz Godzik
158+
1 Vaastav Arora
159+
1 Vadim Chelyshov
160+
1 Will Sargent
161+
1 Zofia Bartyzel
162+
1 Dale Wijnand
163+
1 Bjorn Regnell
164+
1 dmitrii.naumenko
165+
1 Adrien Piquerez
166+
1 Meriam Lachkar
167+
1 Martin
168+
1 Olivier Blanvillain
169+
1 Lorenzo Gabriele
170+
171+
```
172+
173+
## Library authors: Join our community build
174+
175+
Scala 3 now has a set of widely-used community libraries that are built against every nightly Scala 3 snapshot.
176+
Join our [community build](https://github.com/lampepfl/dotty/tree/master/community-build)
177+
to make sure that our regression suite includes your library.
178+
179+
[Scastie]: https://scastie.scala-lang.org/?target=dotty
180+
181+
[@odersky]: https://github.com/odersky
182+
[@DarkDimius]: https://github.com/DarkDimius
183+
[@smarter]: https://github.com/smarter
184+
[@felixmulder]: https://github.com/felixmulder
185+
[@nicolasstucki]: https://github.com/nicolasstucki
186+
[@liufengyun]: https://github.com/liufengyun
187+
[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain
188+
[@biboudis]: https://github.com/biboudis
189+
[@allanrenucci]: https://github.com/allanrenucci
190+
[@Blaisorblade]: https://github.com/Blaisorblade
191+
[@Duhemm]: https://github.com/Duhemm
192+
[@AleksanderBG]: https://github.com/AleksanderBG
193+
[@milessabin]: https://github.com/milessabin
194+
[@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.1
6-
release_date: "July 9, 2021"
5+
release_version: 3.0.2
6+
release_date: "September 1, 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.1"
12+
mainTitle: "Scala 3.0.2"
1313
mainUrl: "/download/scala3.html"
1414
subtitle: "Documentation"
1515
subtitleLink: "https://docs.scala-lang.org/scala3"

0 commit comments

Comments
 (0)