Skip to content

Commit 26106d1

Browse files
authored
Merge pull request #1393 from Kordyjan/announcement-3.1.3
Prepare the 3.1.3 release blogpost
2 parents e30e80a + 620fa79 commit 26106d1

File tree

5 files changed

+168
-2
lines changed

5 files changed

+168
-2
lines changed

_data/scala-releases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
- category: current_version
22
title: Current 3.1.x release
3-
version: 3.1.2
4-
release_date: April 12, 2022
3+
version: 3.1.3
4+
release_date: June 21, 2022
55
- category: current_version
66
title: Current 2.13.x release
77
version: 2.13.8

_downloads/2022-06-21-3.1.3.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Scala 3.1.3
3+
start: 21 June 2022
4+
layout: downloadpage
5+
release_version: 3.1.3
6+
release_date: "June 21, 2022"
7+
permalink: /download/3.1.3.html
8+
license: <a href="https://www.scala-lang.org/license/">Apache License, Version 2.0</a>
9+
api_docs: https://www.scala-lang.org/api/3.1.3/
10+
---
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
layout: blog-detail
3+
post-type: blog
4+
by: Paweł Marks, VirtusLab
5+
title: Scala 3.1.3 released!
6+
---
7+
8+
We are happy to announce the release of Scala 3.1.3! You can read more about all the improvements and fixes in [the full changelog](https://github.com/lampepfl/dotty/releases/tag/3.1.3). We have also prepared a short list of highlights of the most exciting additions in the new version.
9+
10+
## Highlights of the release
11+
12+
### Improved f-interpolator
13+
14+
f-interpolator in Scala 3 has received multiple fixes and improvements recently. Now it has reached feature parity with its Scala 2 counterpart.
15+
16+
- Cases that were incorrectly failing are now working as intended:
17+
18+
```scala
19+
f"${3.14}%.2f rounds to ${3}%d" // "3.14 rounds to 3"
20+
f"${java.lang.Boolean.valueOf(false)}%b" // "false"
21+
f"${BigInt(120)}%d" // "120"
22+
f"${3L}%e" // "3.000000e+00"
23+
```
24+
25+
- Backslash escapes are now handled properly and consistently:
26+
27+
```scala
28+
f"yes\\\no" // "yes\
29+
// o"
30+
```
31+
32+
- Many cases that were throwing runtime exceptions are now causing compilation errors instead:
33+
34+
```scala
35+
f"{1} % y" // Error: illegal conversion character 'y'
36+
```
37+
38+
### Better error reporting in inlined code
39+
40+
When the compiler reports an error that occurred in inlined code, it now displays the source from where the inlined function was invoked. That gives more context to the users on what happened and where the error came from.
41+
42+
For example, the snippet:
43+
44+
```scala
45+
trait Foo[X]:
46+
def foo: Int
47+
48+
def foo =
49+
first[String]
50+
51+
inline def second[A]: Int =
52+
compiletime.summonInline[Foo[A]].foo
53+
54+
inline def first[A]: Int =
55+
second[A] + 42
56+
```
57+
58+
will now report a compilation error looking like this
59+
60+
![the new error]({{ site.baseurl }}/resources/img/inline-error-after.png)
61+
62+
instead of previously
63+
64+
![the old error]({{ site.baseurl }}/resources/img/inline-error-before.png)
65+
66+
### Possibility to generate arbitrary class implementations in macros
67+
68+
For a long time, generating arbitrary classes was not possible using the quotes api. With 3.1.3, the situation has changed. We added two missing blocks: experimental methods `ClassDef.apply` and `Symbol.newClass`. Now using them, you can write a snippet similar to the following:
69+
70+
```scala
71+
import scala.quoted.*
72+
73+
class Base
74+
75+
transparent inline def classNamed(inline name: String) = ${ classNamedExpr('name) }
76+
def classNamedExpr(nameExpr: Expr[String])(using Quotes): Expr[Any] =
77+
import quotes.reflect.*
78+
79+
val name = nameExpr.valueOrAbort
80+
val parents = List(TypeTree.of[Base])
81+
def decls(cls: Symbol) = List.empty // put something interesting here
82+
val body = List.empty // ...and here
83+
84+
val symbol = Symbol.newClass(Symbol.spliceOwner, name, parents.map(_.tpe), decls, selfType = None)
85+
val classDef = ClassDef(symbol, parents, body)
86+
val ctor = Select(New(TypeIdent(symbol)), symbol.primaryConstructor)
87+
val newClass = Typed(Apply(ctor, Nil), TypeTree.of[Base])
88+
89+
Block(List(classDef), newClass).asExprOf[Base]
90+
```
91+
92+
Then you can invoke the macro with
93+
94+
```scala
95+
val impl: Base = classNamed("Foo")
96+
```
97+
98+
creating the new instance of your custom subclass of `Base`. That can be useful for the compile-time generation of proxies for remote procedure call systems and many other advanced use-cases.
99+
100+
## Contributors
101+
102+
Thank you to all the contributors who made this release possible.
103+
104+
According to `git shortlog -sn --no-merges 3.1.2..3.1.3` these are:
105+
106+
```
107+
66 odersky
108+
48 Nicolas Stucki
109+
38 Filip Zybała
110+
36 Martin Odersky
111+
29 noti0na1
112+
27 Som Snytt
113+
24 Dale Wijnand
114+
19 Anatolii Kmetiuk
115+
19 Chris Kipp
116+
18 Paweł Marks
117+
17 Rikito Taniguchi
118+
13 Xavientois
119+
13 Tom Grigg
120+
12 Jan Chyb
121+
11 Guillaume Martres
122+
8 Jamie Thompson
123+
8 Matt Bovel
124+
6 Tomasz Godzik
125+
5 Michael Pilquist
126+
5 rochala
127+
4 adampauls
128+
4 Kacper Korban
129+
3 Sébastien Doeraene
130+
3 Andrzej Ressel
131+
3 Olivier Blanvillain
132+
3 Phil
133+
3 Seth Tisue
134+
2 Stéphane Micheloud
135+
2 Yichen Xu
136+
2 Arman Bilge
137+
2 Julien Richard-Foy
138+
2 Adrien Piquerez
139+
1 ireina7
140+
1 Alexander Ioffe
141+
1 Jentsch
142+
1 Jędrzej Rochala
143+
1 Michał Pałka
144+
1 Ondrej Lhotak
145+
1 Pascal Weisenburger
146+
1 Quentin Bernet
147+
1 Ruslan Shevchenko
148+
1 SrTobi
149+
1 Stephane MICHELOUD
150+
1 Vadim Chelyshov
151+
1 Vasil Vasilev
152+
1 bjornregnell
153+
1 ghostbuster91
154+
1 som-snytt
155+
1 Łukasz Wroński
156+
```

resources/img/inline-error-after.png

66 KB
Loading

resources/img/inline-error-before.png

40.3 KB
Loading

0 commit comments

Comments
 (0)