- Notifications
You must be signed in to change notification settings - Fork3.1k
Scala 2.13.4
Scala 2.13.4:
- Restores default global
ExecutionContextto 2.12 behavior - Improves pattern matching, especially in exhaustivity checking
- Adds experimental support for consuming some libraries built by Scala 3
and more! Details below.
Concurrency
NOTE The following change affects parallelism and performance. If you usescala.concurrent.ExecutionContext.global you may want to adapt your code. (But note that Akka is unaffected, because it uses its own execution contexts.)
In 2.13.0 we madeExecutionContext.global "opportunistic". This enabled "batching" of nested tasks to execute on the same thread, avoiding an expensive context switch. That strategy requires user code to wrap long-running and/or blocking tasks withblocking { ... } to maintain parallel execution.
For 2.13.4, we restore 2.12's default non-batching behavior, which is safer for arbitrary user code. Users wanting increased performance may override the default, if they believe their code usesblocking correctly. We make that choice available viaExecutionContext.opportunistic.
UsingExecutionContext.opportunistic requires a bit of extra boilerplate, made necessary by binary compatibility constraints on the standard library. Detailed instructions are inExecutionContext.global's Scaladoc.
Further detail:#9270/#9296/scala/bug#12089,
Pattern matching
The pattern matcher is now much better at warning you if a match isn't exhaustive.
The following types of matches no longer disable exhaustivity checking:
- guards (
case <pattern> if <condition> => ...)#9140 - custom extractors (user-defined
unapplyorunapplySeq)#9140/#9162 - unsealed types, if you opt in via
-Xlintor-Xlint:strict-unsealed-patmat#9140/#9299
Additionally,
- private classes are now treated as if sealed#9211
- singleton types no longer prematurely widen#9209
- tuples are handled properly#9147/#9163/#9147
New warnings reported can be resolved by:
- adding any missing cases
- in the case of complementary guards (e.g.
if n > 0andif n <= 0) by dropping the last guard - for custom extractors: demarking irrefutable extractors as such, by defining the return type as
Some - for sealed types: marking traits or parent classes sealed, parent classes abstract, and classes final
- explicitly declaring the default case:
case x => throw new MatchError(x)
Otherwise, your options for suppressing warnings include:
- annotate the scrutinee with
@unchecked, such as(foo: @unchecked) match { ... } - disable exhaustivity checking in the presence of guards and custom extractors with
-Xnon-strict-patmat-analysis - disable exhaustivity checking of unsealed types with
-Xlint:-strict-unsealed-patmat - use
-Wconfto suppress the warnings globally, with e.g.-Wconf:msg=match may not be exhaustive:i
Scala 3 interop
This release enables the Scala 2 compiler to consume some libraries built in Scala 3.#9109/#9293
The new capability is experimental. To enable it, add-Ytasty-reader to your compiler options.
Not all Scala 3 built libraries are supported, because not all Scala 3 features can be supported. The library author must stay within the supported subset.
For more details and caveats see the blog postForward Compatibility for the Scala 3 Transition.
Standard library changes
- When compiling on JDK 15, avoid clash with new
CharSequence#isEmptymethod#9292- The clash is avoided by making
CharSequencewrappers inPredefnon-implicit. - The change is binary compatible, but not source compatible. Call sites may need updating.
- The clash is avoided by making
- Make
LazyList.cons.applylazier#9095 - Make
MapView#valuespreserve laziness#9090 - Make
ListBuffer's iterator fail when the buffer is mutated#9174 - Un-deprecate useful
StringOpsmethods, despite Unicode concerns#9246
Compiler changes
- Allow using
classOfwith object type (e.g.classOf[Foo.type])#9279 - Fix back-quoted constructor params with identical prefixes#9008
- Enable range positions (
-Yrangepos) by default#9146
Other changes
Some changes that will also ship in 2.12.13 are also included in this release, most notably:
- When compiling on JDK 15, avoid clash with new
CharSequence#isEmptymethod#9292- To avoid the clash,
implicitwas removed fromPredef's implicit conversions toSeqCharSequenceandArrayCharSequence. - This change is binary compatible, but not source compatible. User code may need updating. See PR for details.
- To avoid the clash,
For complete 2.13.4 change lists, seeall merged PRs andall closed bugs.
Compatibility
As usual for our minor releases, Scala 2.13.4 is binary-compatible with the whole Scala 2.13 series.
Upgrading from 2.12? Enable-Xmigration while upgrading to request migration advice from the compiler.
Contributors
A big thank you to everyone who's helped improve Scala by reporting bugs, improving our documentation, spreading kindness in discussions around Scala, and submitting and reviewing pull requests! You are all magnificent.
This release was brought to you by 40 contributors, according togit shortlog -sn --no-merges HEAD ^v2.13.3 ^2.12.x. Thank you Jamie Thompson, Dale Wijnand, A. P. Marki, NthPortal, Lukas Rytz, Seth Tisue, Jason Zaugg, Georgi Krastev, Eugene Yokota, Martijn Hoekstra, Trey Cahill, Rado Buransky, Ergys Dona, Mike Skells, Greg Pfeil, Kazuhiro Sera, Mitsuhiro Shibuya, NagaChaitanya Vellanki, Sergei Petunin, Sébastien Doeraene, Takahashi Osamu, Viktor Klang, mwielocha, Nicolas Stucki, Jan Arne Sparka, Philippus Baalman, Glenn Liwanag, Rafał Sumisławski, Renato Cavalcanti, Sergei, nooberfsh, Dmitrii Naumenko, Simão Martins, counter2015, Jian Lan, Liu Fengyun, Kanishka, Julien Richard-Foy, Janek Bogucki, Björn Regnell.
Thanks toLightbend for their continued sponsorship of the Scala core team’s efforts. Lightbend offerscommercial support for Scala.
Scala 2.13 notes
Therelease notes for Scala 2.13.0 have important information applicable to the whole 2.13 series.
Obtaining Scala
Scala releases are available through a variety of channels, including (but not limited to):
- Bump the
scalaVersionsetting in your sbt-based project - Download a distribution fromscala-lang.org
- Obtain JARs viaMaven Central
Assets9
Uh oh!
There was an error while loading.Please reload this page.