Skip to content

Commit e737ce3

Browse files
committed
Add 3.4.0 blogpost
1 parent 1bc77c6 commit e737ce3

File tree

1 file changed

+187
-0
lines changed

1 file changed

+187
-0
lines changed
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
layout: blog-detail
3+
post-type: blog
4+
by: Paweł Marks, VirtusLab
5+
title: Scala 3.4.0 and 3.3.2 LTS released!
6+
---
7+
We are thrilled to announce the release of two awaited versions of Scala: the first one in the 3.4 minor line and the patch for the Long Term Support line.
8+
9+
## ... so which version should I update to?
10+
11+
Scala 3.4.0 and 3.3.2 share most of the changes compared to the 3.3.1 version. The difference is that while there are new features and deprecations of legacy mechanisms in Scala 3.4.0, version 3.3.2 is focused solely on bug fixes and usability improvements. What's more, it maintains not only full output compatibility but also full source compatibility. **This means that every single one from over a thousand projects that we have checked that worked correctly with 3.3.1 is also working now with 3.3.2.** This required us to be extra careful with picking changes for that release. Because of that, not every bug that is fixed in 3.4.0 is also fixed in 3.3.2. Some of the not-ported changes only require some additional work, so you may expect them in 3.3.3.
12+
13+
Scala 3.4.0 code can depend on dependencies compiled with Scala 3.3.x, but not the other way around. That means that if you are a library author, you should consider staying on the LTS line. If you are working on a project that is not meant to be used as an external dependency, feel free to update to Scala 3.4.0, especially if you are starting a new project.
14+
15+
## What's new in 3.3.2 LTS and 3.4.0
16+
17+
If you go through the release notes of Scala [3.3.2 LTS](https://github.com/lampepfl/dotty/releases/tag/3.3.2) and [3.4.0](https://github.com/lampepfl/dotty/releases/tag/3.4.0), you can see a lot of bug fixes. One area that received special attention in that regard was coverage support. With most pains fixed, we are right now confident in the state of coverage.
18+
19+
The other important, but invisible at first, change is integration of the presentation compiler into the compiler itself. This simplifies the lives of tooling developers and allows for a more stable and reliable user experience when using Metals.
20+
21+
## Changes exclusive to 3.4.0
22+
23+
- It is now possible to write a polymorphic lambda without writing down the types of its value parameters as long as they can be inferred from the context, for example:
24+
25+
```scala
26+
val f: [T] => T => String = [T] => (x: T) => x.toString
27+
```
28+
29+
can now be written more concisely as:
30+
31+
```scala
32+
val f: [T] => T => String = [T] => x => x.toString
33+
```
34+
35+
- Polymorphic lambdas are now implemented using JVM lambdas when possible instead of anonymous classes, which will make them more efficient.
36+
- Match types are now properly specified, and thanks to that, they work in a more predictable and stable way. See [SIP-56](https://docs.scala-lang.org/sips/match-types-spec.html)
37+
- [SIP-54](https://docs.scala-lang.org/sips/multi-source-extension-overloads.html) is now a standard feature. It allows for importing extension methods with the same name from different sources.
38+
- [SIP-53](https://docs.scala-lang.org/sips/quote-pattern-type-variable-syntax.html) is now a standard feature. It allows for more expressive type patterns in quotes. For example:
39+
40+
```scala
41+
case '[ (t, t, t) ] => ???
42+
```
43+
44+
will match any 3-element tuple, and `t` will be the greatest lower bound of types of all three elements.
45+
- An experimental `@publicInBinary` annotation can mark definitions that should be treated as a part of binary API. It is useful where some protected or private-in-package definitions are used in the inlined code. When they are marked, it is harder to accidentally break the binary compatibility by doing seemingly harmless refactoring. If the accompanying `-WunstableInlineAccessors` linting option is enabled. There will be a warning about using things not marked as binary API in inlined code.
46+
- `-experimental` compiler flags will mark all top-level definitions as `@experimental`. This means that the experimental language features and definitions can be used in the project. Note that this does not change the strong guarantees of the stability of the non-experimental code. The experimental features can only be used in an experimental scope (transitively). In 3.5, we plan to allow using this flag also in the stable releases of the compiler.
47+
- If there is an error reading a class file, we now report the version of the classfile and a recommendation to check JDK compatibility:
48+
49+
```
50+
error while loading String,
51+
class file /modules/java.base/java/lang/String.class is broken (version 65.0),
52+
please check the JDK compatibility of your Scala version (3.4.0),
53+
reading aborted with class java.lang.RuntimeException:
54+
foo bar
55+
```
56+
57+
This will improve the user experience when the class file format changes unexpectedly. This feature will be backported to Scala 3.3.3.
58+
- Type inference for functions similar to fold is greatly improved. For example:
59+
60+
```scala
61+
def partition[T](xs: List[T], pred: T => Boolean) =
62+
xs.foldRight((Nil, Nil)): (x, p) =>
63+
if pred(x) then (x :: p._1, p._2) else (p._1, x :: p._2)
64+
65+
```
66+
67+
will have its return type correctly inferred as `(List[T], List[T])`. Earlier, it would result in a rather unintuitive type error.
68+
- In 3.4, refutable patterns (i.e., patterns that might not match) in a for-comprehension generator must now be preceded by `case`, or an error is reported.
69+
70+
e.g.
71+
72+
```scala
73+
val xss = List(List(1, 2), List(3))
74+
75+
for y :: ys <- xss do println(y > 1)
76+
// ^^^^^^^
77+
// error: pattern's type ::[Int] is more specialized than the right hand
78+
// side expression's type List[Int]
79+
//
80+
// If the narrowing is intentional, this can be communicated by adding
81+
// the `case` keyword before the full pattern, which will result in a filtering
82+
// for expression (using `withFilter`).
83+
```
84+
85+
`.withFilter` is also no longer inserted for a pattern in a generator unless prefixed by `case`, meaning improved ergonomics for many types that do not implement `.withFilter`
86+
- Type inference has changed for `inline` methods in 3.4, which can cause a source incompatibility at the call site. The previous behaviour can be recovered in an affected file with
87+
88+
```scala
89+
import scala.language.`3.3`
90+
```
91+
92+
alternatively, the definition can changed to transparent inline, but as this is a TASTy breaking change, it is not a default recommendation. (Also, `inline` should be preferred when possible over `transparent inline` for reduced binary size)
93+
- JVM Backend parallelization has been ported from Scala 2.13 to Scala 3.
94+
- The compiler now avoids generating given definitions that loop, removing long-standing footman of implicit resolution.
95+
96+
### Road to Pipelined Builds
97+
98+
We made the next concrete preparation for introducing pipelined Scala 3 builds. Now TASTy can store outline signatures and, additionally, the signatures of Java source files. This is the only TASTy breaking change required to introduce pipelining, which means that once it is ready, pipelined build support will be able to be released in an upcoming patch version of Scala Next.
99+
100+
- outline signatures (enabled with the `OUTLINEattr` TASTy attribute) only store what is necessary for separate compilation (i.e., method bodies can be elided). This will enable in the future the possibility of a faster type checking phase because a lot of work is no longer necessary to produce this outline TASTy. Elided expressions are represented by the new `ELIDED` tree in TASTy.
101+
- Java signatures (enabled with the `JAVAattr` TASTy attribute) can be produced faster than waiting for class files from `javac`, which will be necessary to enable pipelined builds that include Java sources.
102+
103+
## Contributors
104+
105+
Thank you to all the contributors who made the release of 3.4.0 and 3.3.2 LTS possible
106+
107+
According to `git shortlog -sn --no-merges 3.3.1..3.4.0` these are:
108+
109+
```
110+
474 Martin Odersky
111+
296 Nicolas Stucki
112+
132 Fengyun Liu
113+
119 Dale Wijnand
114+
77 Jamie Thompson
115+
69 Sébastien Doeraene
116+
60 Paweł Marks
117+
32 Chris Kipp
118+
27 Guillaume Martres
119+
26 Rikito Taniguchi
120+
21 Yichen Xu
121+
19 EnzeXing
122+
14 Szymon Rodziewicz
123+
13 Lucas Leblanc
124+
12 Jakub Ciesluk
125+
12 Jędrzej Rochala
126+
12 Katarzyna Marek
127+
11 Carl
128+
10 David Hua
129+
9 Florian3k
130+
9 Wojciech Mazur
131+
8 Eugene Flesselle
132+
8 ghostbuster91
133+
7 Hamza Remmal
134+
7 Jan Chyb
135+
7 Ondrej Lhotak
136+
7 Quentin Bernet
137+
6 Julien Richard-Foy
138+
6 Kacper Korban
139+
6 Seth Tisue
140+
5 Lorenzo Gabriele
141+
5 Matt Bovel
142+
5 Som Snytt
143+
5 Yuito Murase
144+
5 dependabot[bot]
145+
3 David
146+
3 Lucas
147+
3 Pascal Weisenburger
148+
3 Tomasz Godzik
149+
2 Aleksander Rainko
150+
2 Decel
151+
2 Guillaume Raffin
152+
2 Ondřej Lhoták
153+
2 Oron Port
154+
2 danecek
155+
2 rochala
156+
1 Adam Dąbrowski
157+
1 Aleksey Troitskiy
158+
1 Arnout Engelen
159+
1 Ausmarton Zarino Fernandes
160+
1 Bjorn Regnell
161+
1 Daniel Esik
162+
1 Eugene Yokota
163+
1 Fabián Heredia Montiel
164+
1 François Monniot
165+
1 Jakub Cieśluk
166+
1 John Duffell
167+
1 John M. Higgins
168+
1 Justin Reardon
169+
1 Kai
170+
1 Kisaragi
171+
1 Lucas Nouguier
172+
1 Lukas Rytz
173+
1 LydiaSkuse
174+
1 Martin Kucera
175+
1 Martin Kučera
176+
1 Matthew Rooney
177+
1 Matthias Kurz
178+
1 Mikołaj Fornal
179+
1 Nicolas Almerge
180+
1 Preveen P
181+
1 Shardul Chiplunkar
182+
1 Stefan Wachter
183+
1 philippus
184+
1 q-ata
185+
1 slim
186+
187+
```

0 commit comments

Comments
 (0)