-
Notifications
You must be signed in to change notification settings - Fork 325
Prepare the 3.1.3 release blogpost #1393
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
Changes from 3 commits
cacfdb0
c435372
fc2f6ae
28f1be5
e441433
620fa79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
--- | ||
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 highlights of the most exciting additions in the new version. | ||
|
||
## Highlights of the release | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scala/scala3#15275 - porting of scalac from bash to scala - will enable scala/scala3#15355 - windows batch files now match bash script launchers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is an essential change for most of our users. A lot of users are not aware of existence of launch scripts. Those who use them will also not see immediate improvements, as (if I remember correctly) this is just a new implementation with the same functionality. The coursier part may be interesting, but it is still not implemented, so I wouldn't put that in the release notes. |
||
### 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 compilation error looking like this | ||
Kordyjan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
 | ||
|
||
instead of previous | ||
Kordyjan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
 | ||
|
||
### 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: | ||
|
||
``` | ||
// TODO | ||
``` |
Uh oh!
There was an error while loading. Please reload this page.