You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/_posts/2022-01-17-scala-3.1.1-released.md
+14-11Lines changed: 14 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@ by: Paweł Marks, VirtusLab
5
5
title: Scala 3.1.1 and forward compatibility news
6
6
---
7
7
8
-
Hello from the Scala 3 team! After a slightly longer than usual pause, we are back with a new release of the Scala compiler and exciting news about improvements in forward compatibility. The delay in the release was caused by urgent bugs that needed backporting and testing, and then the holiday season.
8
+
Hello from the Scala 3 team! We are back with a new release of the Scala compiler and exciting news about improvements in forward compatibility.
9
9
10
10
## Improvements is Scala 3.1.1
11
11
12
-
Scala 3.1.1-RC2 was promoted to a full stable release of the language. Scala 3.1.1 is the first patch version after the 3.1 minor release. It is therefore focused on bug fixes and improvements in overall correctness and stability. Although there are no new additions to the language, you can still spot some noticeable improvements:
12
+
Scala 3.1.1is the patch releasefocused on bug fixes. Although there are no new additions to the language, you can still spot some noticeable improvements:
13
13
14
-
- You can use `using` clauses to introduce Scala 2 conversions.
14
+
- You can use `using` clauses to introduce subtyping relations between types in the function body.
15
15
16
-
Now the code like this should compile and perform necessary conversion from `A` to `B` in the method body:
16
+
Now the code like this should compile. Any value of type `A`can be assigned to a value of type `B`:
17
17
18
18
```scala
19
19
defexample[A, B](a: A)(usingA<:<B) =
@@ -22,25 +22,28 @@ Scala 3.1.1-RC2 was promoted to a full stable release of the language. Scala 3.1
22
22
```
23
23
24
24
To know more see [PR #13662](https://github.com/lampepfl/dotty/pull/13662) and [related issue](https://github.com/lampepfl/dotty/issues/12955).
25
-
- Mirrors can be correctly summoned for hierarchical sum types compiled by Scala 3.0.x ([PR #14100](https://github.com/lampepfl/dotty/pull/14100)).
25
+
- Mirrors can be correctly summoned for hierarchical sum types compiled by Scala 3.0.x. You can now safely create derived instances of type classes for the types defined in dependencies compiled with previous versions of the compiler. ([PR #14100](https://github.com/lampepfl/dotty/pull/14100)).
26
26
- Dual Scala 2/3 macros can be now declared in non-experimental scopes ([PR #13795](https://github.com/lampepfl/dotty/pull/13795)).
27
-
- Scaladoc can correctly handle symbolic class names, such as `/` or `\` ([PR #13827](https://github.com/lampepfl/dotty/pull/13827)).
28
-
- Scaladoc documentation has a new, improved UI.
27
+
- Scaladoc documentation has an improved UI.
29
28
30
29
For a comprehensive list of fixes, take a look at [the full changelog on GitHub](https://github.com/lampepfl/dotty/releases/tag/3.1.1).
31
30
32
31
## 3.1.2-RC1 and forward compatibility improvements
33
32
34
-
Scala 3 has excellent backward compatibility guarantees between the minor versions. On the other hand, after the recent release of Scala 3.1, we can see that the libraries should be really cautious with updating the compiler version, as it is forcing the bump on every user of that library. We do not want library authors to be stuck on old versions of the compiler as that would mean that they are locked out of many bugfixes, or we would need to spend enormous effort on backporting every bugfix to all past versioning lines.
33
+
Together with 3.1.1 we have released first RC versionof next patch release of the compiler. 3.1.2-RC1 contains further fixes, but most importantly it is our first step in improving forward compatibility in scala.
35
34
36
-
We are sure we want to mitigate those difficulties. We already have implemented the first and most important part of the solution and have it ready for public testing. Beginning in Scala 3.1.2-RC1, that was just released, compiler is able to generate output that can be consumed by older versions. To enable that, you need to specify a minimum version of the language using the experimental `-Yscala-release` flag.
35
+
Scala 3 has excellent backward compatibility guarantees between the minor versions. Right now, that means that code compiled with Scala 3.1 can depend on libraries published with 3.0 without any problems. The opposite, hovewer, is not true. Code compiled with 3.0 is not able to read dependencies compiled with 3.1. After the recent release of Scala 3.1.0, we can see that the libraries should be really cautious with updating the compiler version, as it is forcing the bump on every user of that library. We do not want library authors to be stuck on old versions of the compiler as that would mean that they are locked out of many bugfixes, or we would need to spend enormous effort on backporting every bugfix to all past versioning lines.
37
36
38
-
So, for example, compiling your library using Scala 3.1.2-RC2 with `-Yscala-release:3.0` flag, you make it possible for people still using Scala 3.0 to depend on your library. This has one limitation, you won't be able to use any symbol added to the standard library after 3.0. They are marked in the code and in the documentation by the internal `@since` annotation that was also added in this version.
37
+
We are sure we want to mitigate those difficulties. We already have implemented the first and most important part of the solution and have it ready for public testing. Beginning in Scala 3.1.2-RC1 compiler is able to generate output that can be consumed by older versions. To enable that, you need to specify a minimum version of the language using the experimental `-Yscala-release` flag.
39
38
40
-
Those restrictions are not final, and in the future, we may decide to allow using some functions from the newer versions of the standard library and to make the `@since` annotation public.
39
+
We expect that in the future authors will use the newest available version of the compiler with `-Yscala-release` set to the lowest language version that support all features they need. This way they will be able to benefit from the all bugfixes without restricting their potential audience.
40
+
41
+
So, for example, compiling your library using Scala 3.1.2-RC2 with `-Yscala-release:3.0` flag, you make it possible for people still using Scala 3.0 to depend on your library. This has one limitation, you won't be able to use any symbol added to the standard library after 3.0. They are marked in the code and in the documentation by the `@since` annotation that was also added in this version.
41
42
42
43
One important note is that the `-Yscala-release` flag is experimental and not yet available in any stable release of the compiler. It means the build tools, such as SBT or Mill, are not yet aware of its existence. Of course, you can declare usage of the flag in your build file, and the compiler will respect it. However, there may still be some hiccups, like generated artifacts depending on the incorrect version of the stdlib. We will do our best to help fix those minor issues before the stable release of 3.1.1.
43
44
45
+
You can read about potential next steps and leave your feedback in [the discussion](https://contributors.scala-lang.org/t/improving-scala-3-forward-compatibility/5298) that initiaded this change.
46
+
44
47
If you are interested in other changes brought by 3.1.2-RC1, there is, as always, [a changelog on GitHub](https://github.com/lampepfl/dotty/releases/tag/3.1.2-RC1).
0 commit comments