Skip to content

Commit 6c33e1a

Browse files
authored
Merge pull request #1259 from prolativ/scala-3.0.2-RC1-release-article
Add blogpost for releases 3.0.1 and 3.0.2-RC1
2 parents 5059364 + 9bd6c8b commit 6c33e1a

File tree

1 file changed

+229
-0
lines changed

1 file changed

+229
-0
lines changed
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
---
2+
layout: blog-detail
3+
post-type: blog
4+
by: Michał Pałka, VirtusLab
5+
title: Scala 3.0.1 and 3.0.2-RC1 are here!
6+
---
7+
8+
Greetings from the Scala 3 team! We are glad to announce that Scala 3.0.1 and 3.0.2-RC1 are now officially out.
9+
10+
As no critical bugs have been found in the previously released Scala 3.0.1-RC2, it has been promoted to 3.0.1. It is the first stable release after 3.0.0 and it incorporates the changes described in detail in the articles for its pre-releases: [3.0.1-RC1](https://dotty.epfl.ch/blog/2021/06/07/scala3.0.1-rc1-release.html) and [3.0.1-RC2](https://dotty.epfl.ch/blog/2021/06/25/scala301-rc2.html). The unified changelog can be found [here](https://github.com/lampepfl/dotty/releases/tag/3.0.1).
11+
12+
Scala 3.0.2-RC1, in turn, incorporates new language improvements and bug fixes described below.
13+
14+
You can expect the release of stable 3.0.2 and a release candidate for a the next version in 6 weeks from now (1st September).
15+
16+
# Improved insertion of semicolons in logical conditions
17+
18+
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.
19+
20+
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.
21+
22+
```scala
23+
if foo
24+
(bar)
25+
then //...
26+
```
27+
28+
can now be used instead of
29+
30+
```scala
31+
if foo(bar)
32+
then //...
33+
```
34+
35+
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.
36+
37+
```scala
38+
if
39+
val cond = foo(bar)
40+
cond
41+
then //...
42+
```
43+
44+
so code like below would NOT be valid
45+
46+
```scala
47+
if val cond = foo(bar)
48+
cond
49+
then //...
50+
```
51+
52+
# Towards better null safety in the type system
53+
54+
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).
55+
56+
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).
57+
58+
```scala
59+
def foo[T <: Matchable](t: T) = t match { case null => () }
60+
```
61+
62+
# Method search by type signature
63+
64+
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).
65+
66+
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).
67+
68+
![image url "image Title"](https://user-images.githubusercontent.com/39772805/117478350-53f12a80-af5f-11eb-82ab-930ba565dacb.gif)
69+
70+
# Typing escape hatch for structural types
71+
72+
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.
73+
74+
```scala
75+
class Sink[A] { def put(x: A): Unit = {} }
76+
val a = Sink[String]()
77+
val b: { def put(x: String): Unit } = a
78+
```
79+
80+
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 }`.
81+
82+
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`.
83+
84+
```scala
85+
import annotation.experimental
86+
87+
@experimental trait MultiMethodSelectable extends Selectable.WithoutPreciseParameterTypes:
88+
// smartly choose the right method implementation to call
89+
def applyDynamic(name: String, paramTypes: Class[_]*)(args: Any*): Any = ???
90+
91+
@experimental class Sink[A] extends MultiMethodSelectable:
92+
def put(x: A): Unit = {}
93+
94+
val a = new Sink[String]
95+
val b: MultiMethodSelectable { def put(x: String): Unit } = a
96+
```
97+
98+
This snippet will compile as the compiler won't perform the precise signature check for `b` anymore.
99+
100+
[More details](https://dotty.epfl.ch/docs/reference/changed-features/structural-types-spec.html#limitations-of-structural-types)
101+
102+
# Metaprogramming
103+
104+
Keeping in mind how important metaprogramming has become to Scala developers (especially creators of libraries) we continue to make it more reliable by fixing reported bugs and more powerful by repealing formerly introduced limitations. If you're curious how it was done look at the PRs below:
105+
106+
- Map opaque types in arguments of inlined calls to proxies [#12922](https://github.com/lampepfl/dotty/pull/12922)
107+
- Don't forget side effects in prefixes of inlined function calls [#12842](https://github.com/lampepfl/dotty/pull/12842)
108+
- Drop "no inlines with opaques" implementation restriction [#12815](https://github.com/lampepfl/dotty/pull/12815)
109+
- Detect abstract inline method calls after inlining [#12777](https://github.com/lampepfl/dotty/pull/12777)
110+
- Fix implicit ValueOf synthesis [#12615](https://github.com/lampepfl/dotty/pull/12615)
111+
112+
# Other notable improvements
113+
114+
- Add Scala 3 batch commands for Windows [#13006](https://github.com/lampepfl/dotty/pull/13006)
115+
- Fix [#12981](https://github.com/lampepfl/dotty/issues/12981): show diagnostics levels (warn | error) in REPL [#13000](https://github.com/lampepfl/dotty/pull/13000)
116+
- Add no links warning setting to scaladoc [#12936](https://github.com/lampepfl/dotty/pull/12936)
117+
- Use WeakHashSet instead of HashSet for hash-consing types [#12935](https://github.com/lampepfl/dotty/pull/12935)
118+
- Balance And/Or types when forming lubs and glbs [#12928](https://github.com/lampepfl/dotty/pull/12928)
119+
- Restricts isInstanceOf[Null] checks [#12905](https://github.com/lampepfl/dotty/pull/12905)
120+
- Add support for shallow capture sets [#12875](https://github.com/lampepfl/dotty/pull/12875)
121+
- Drop implementation restriction for polymorphic functions [#12863](https://github.com/lampepfl/dotty/pull/12863)
122+
- Preserve hard unions in more situations [#12654](https://github.com/lampepfl/dotty/pull/12654)
123+
- Better support type-heavy pattern matches [#12549](https://github.com/lampepfl/dotty/pull/12549)
124+
125+
# Other notable bug fixes
126+
127+
- Fix [#13046](https://github.com/lampepfl/dotty/issues/13046): override is a valid identifier in Java, not a keyword [#13048](https://github.com/lampepfl/dotty/pull/13048)
128+
- Don't emit Java generic signatures for constructors [#13047](https://github.com/lampepfl/dotty/pull/13047)
129+
- Exhaustivity warnings on nested case classes [#13030](https://github.com/lampepfl/dotty/pull/13030)
130+
- Refine overriding pairs in RefChecks [#12982](https://github.com/lampepfl/dotty/pull/12982)
131+
- Let annotations on parameters see preceding type parameters [#12980](https://github.com/lampepfl/dotty/pull/12980)
132+
- Retain transparent flag on exports [#12978](https://github.com/lampepfl/dotty/pull/12978)
133+
- Widen unions before finding members [#12925](https://github.com/lampepfl/dotty/pull/12925)
134+
- ProtoTypes#normalizedCompatible: keep more constraints [#12924](https://github.com/lampepfl/dotty/pull/12924)
135+
- Detect provisional superclasses and recompute them in Typer [#12912](https://github.com/lampepfl/dotty/pull/12912)
136+
- Properly handle self-types in reflection member lookup [#12893](https://github.com/lampepfl/dotty/pull/12893)
137+
- Use Java rules for member lookup in .java sources [#12884](https://github.com/lampepfl/dotty/pull/12884)
138+
- Hide problematic static forwarders [#12860](https://github.com/lampepfl/dotty/pull/12860)
139+
- When checking tp1 <:< tycon2[args2], widen tp1 to reveal application [#12846](https://github.com/lampepfl/dotty/pull/12846)
140+
- Skip contexts for implicit search when resolving imports [#12816](https://github.com/lampepfl/dotty/pull/12816)
141+
- Insert conversions also on selections wrapped in type applications [#12719](https://github.com/lampepfl/dotty/pull/12719)
142+
- Emit generic signature for static forwarders to nullary methods [#12710](https://github.com/lampepfl/dotty/pull/12710)
143+
- Add Matchable to the parents of Null in explicit nulls [#12697](https://github.com/lampepfl/dotty/pull/12697)
144+
- Always generate a partial function from a lambda [#12670](https://github.com/lampepfl/dotty/pull/12670)
145+
- Fix [#12572](https://github.com/lampepfl/dotty/issues/12572): Ignore default accessor bridges in non-native JS classes. [#12657](https://github.com/lampepfl/dotty/pull/12657)
146+
147+
# Contributors
148+
Thank you to all the contributors who made this release possible 🎉
149+
150+
According to `git shortlog -sn --no-merges 3.0.1-RC2..3.0.2-RC1` these are:
151+
152+
```
153+
85 Martin Odersky
154+
60 Liu Fengyun
155+
47 Kacper Korban
156+
28 Filip Zybała
157+
17 Andrzej Ratajczak
158+
16 Guillaume Martres
159+
15 Jamie Thompson
160+
10 bjornregnell
161+
9 tanishiking
162+
8 Dylan Halperin
163+
8 Anatolii Kmetiuk
164+
7 Tom Grigg
165+
5 Som Snytt
166+
5 changvvb
167+
4 Nicolas Stucki
168+
4 Aleksander Boruch-Gruszecki
169+
4 Sébastien Doeraene
170+
4 Michał Pałka
171+
3 Magnolia.K
172+
3 Phil
173+
3 Krzysztof Romanowski
174+
3 Paweł Marks
175+
2 xuwei-k
176+
2 Ben Plommer
177+
2 Florian Schmaus
178+
2 Lukas Rytz
179+
2 Maciej Gorywoda
180+
2 Markus Sutter
181+
2 Roman Kotelnikov
182+
2 Stéphane Micheloud
183+
2 noti0na1
184+
2 vincenzobaz
185+
1 Ondrej Lhotak
186+
1 KazuyaMiayshita
187+
1 odersky
188+
1 Julian Mendez
189+
1 Anton Sviridov
190+
1 GavinRay97
191+
1 EnzeXing
192+
1 Tomas Mikula
193+
1 Tomasz Godzik
194+
1 Vaastav Arora
195+
1 Vadim Chelyshov
196+
1 Will Sargent
197+
1 Zofia Bartyzel
198+
1 Dale Wijnand
199+
1 Bjorn Regnell
200+
1 dmitrii.naumenko
201+
1 Adrien Piquerez
202+
1 Meriam Lachkar
203+
1 Martin
204+
1 Olivier Blanvillain
205+
1 Lorenzo Gabriele
206+
```
207+
208+
## Library authors: Join our community build
209+
210+
Scala 3 now has a set of widely-used community libraries that are built against every nightly Scala 3 snapshot.
211+
Join our [community build](https://github.com/lampepfl/dotty/tree/master/community-build)
212+
to make sure that our regression suite includes your library.
213+
214+
[Scastie]: https://scastie.scala-lang.org/?target=dotty
215+
216+
[@odersky]: https://github.com/odersky
217+
[@DarkDimius]: https://github.com/DarkDimius
218+
[@smarter]: https://github.com/smarter
219+
[@felixmulder]: https://github.com/felixmulder
220+
[@nicolasstucki]: https://github.com/nicolasstucki
221+
[@liufengyun]: https://github.com/liufengyun
222+
[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain
223+
[@biboudis]: https://github.com/biboudis
224+
[@allanrenucci]: https://github.com/allanrenucci
225+
[@Blaisorblade]: https://github.com/Blaisorblade
226+
[@Duhemm]: https://github.com/Duhemm
227+
[@AleksanderBG]: https://github.com/AleksanderBG
228+
[@milessabin]: https://github.com/milessabin
229+
[@anatoliykmetyuk]: https://github.com/anatoliykmetyuk

0 commit comments

Comments
 (0)