Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare the 3.1.3 release blogpost #1393

Merged
merged 6 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions _data/scala-releases.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- category: current_version
title: Current 3.1.x release
version: 3.1.2
release_date: April 12, 2022
version: 3.1.3
release_date: June 21, 2022
- category: current_version
title: Current 2.13.x release
version: 2.13.8
Expand Down
10 changes: 10 additions & 0 deletions _downloads/2022-06-21-3.1.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Scala 3.1.3
start: 21 June 2022
layout: downloadpage
release_version: 3.1.3
release_date: "June 21, 2022"
permalink: /download/3.1.3.html
license: <a href="https://www.scala-lang.org/license/">Apache License, Version 2.0</a>
api_docs: https://www.scala-lang.org/api/3.1.3/
---
156 changes: 156 additions & 0 deletions blog/_posts/2022-06-21-scala-3.1.3-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
layout: blog-detail
post-type: blog
by: Paweł Marks, VirtusLab
title: Scala 3.1.3 released!
---

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.

## Highlights of the release

### Improved f-interpolator

f-interpolator in Scala 3 has received multiple fixes and improvements recently. Now it has reached feature parity with its Scala 2 counterpart.

- Cases that were incorrectly failing are now working as intended:

```scala
f"${3.14}%.2f rounds to ${3}%d" // "3.14 rounds to 3"
f"${java.lang.Boolean.valueOf(false)}%b" // "false"
f"${BigInt(120)}%d" // "120"
f"${3L}%e" // "3.000000e+00"
```

- Backslash escapes are now handled properly and consistently:

```scala
f"yes\\\no" // "yes\
// o"
```

- Many cases that were throwing runtime exceptions are now causing compilation errors instead:

```scala
f"{1} % y" // Error: illegal conversion character 'y'
```

### Better error reporting in inlined code

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.

For example, the snippet:

```scala
trait Foo[X]:
def foo: Int

def foo =
first[String]

inline def second[A]: Int =
compiletime.summonInline[Foo[A]].foo

inline def first[A]: Int =
second[A] + 42
```

will now report a compilation error looking like this

![the new error]({{ site.baseurl }}/resources/img/inline-error-after.png)

instead of previously

![the old error]({{ site.baseurl }}/resources/img/inline-error-before.png)

### Possibility to generate arbitrary class implementations in macros

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:

```scala
import scala.quoted.*

class Base

transparent inline def classNamed(inline name: String) = ${ classNamedExpr('name) }
def classNamedExpr(nameExpr: Expr[String])(using Quotes): Expr[Any] =
import quotes.reflect.*

val name = nameExpr.valueOrAbort
val parents = List(TypeTree.of[Base])
def decls(cls: Symbol) = List.empty // put something interesting here
val body = List.empty // ...and here

val symbol = Symbol.newClass(Symbol.spliceOwner, name, parents.map(_.tpe), decls, selfType = None)
val classDef = ClassDef(symbol, parents, body)
val ctor = Select(New(TypeIdent(symbol)), symbol.primaryConstructor)
val newClass = Typed(Apply(ctor, Nil), TypeTree.of[Base])

Block(List(classDef), newClass).asExprOf[Base]
```

Then you can invoke the macro with

```scala
val impl: Base = classNamed("Foo")
```

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.

## Contributors

Thank you to all the contributors who made this release possible.

According to `git shortlog -sn --no-merges 3.1.2..3.1.3` these are:

```
66 odersky
48 Nicolas Stucki
38 Filip Zybała
36 Martin Odersky
29 noti0na1
27 Som Snytt
24 Dale Wijnand
19 Anatolii Kmetiuk
19 Chris Kipp
18 Paweł Marks
17 Rikito Taniguchi
13 Xavientois
13 Tom Grigg
12 Jan Chyb
11 Guillaume Martres
8 Jamie Thompson
8 Matt Bovel
6 Tomasz Godzik
5 Michael Pilquist
5 rochala
4 adampauls
4 Kacper Korban
3 Sébastien Doeraene
3 Andrzej Ressel
3 Olivier Blanvillain
3 Phil
3 Seth Tisue
2 Stéphane Micheloud
2 Yichen Xu
2 Arman Bilge
2 Julien Richard-Foy
2 Adrien Piquerez
1 ireina7
1 Alexander Ioffe
1 Jentsch
1 Jędrzej Rochala
1 Michał Pałka
1 Ondrej Lhotak
1 Pascal Weisenburger
1 Quentin Bernet
1 Ruslan Shevchenko
1 SrTobi
1 Stephane MICHELOUD
1 Vadim Chelyshov
1 Vasil Vasilev
1 bjornregnell
1 ghostbuster91
1 som-snytt
1 Łukasz Wroński
```
Binary file added resources/img/inline-error-after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/inline-error-before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.