Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Scala 2.13.0

Choose a tag to compare

@SethTisueSethTisue released this 07 Jun 12:15
· 7485 commits to 2.13.x since this release
v2.13.0
This tag was signed with the committer’sverified signature.
adriaanm Adriaan Moors
GPG key ID:902877136D21D294
Verified
Learn about vigilant mode.
43e040f
This commit was created on GitHub.com and signed with GitHub’sverified signature. The key has expired.
GPG key ID:4AEE18F83AFDEB23
Expired
Verified
Learn about vigilant mode.

We are delighted to announce the availability of Scala 2.13.0!

Release summary

2.13 improves Scala in the following areas:

  • Collections: Standard library collections have been overhauled for simplicity, performance, and safety. This is the centerpiece of the release.
  • Standard library:Future is faster and more robust. Elsewhere, useful classes and methods have been added.
  • Language: Literal types, partial unification, by-name implicits, more.
  • Compiler: 5-10% faster, deterministic output, improved optimizer.

To learn more, read on.

Collections redesign

Standard library collections have been overhauled for simplicity, performance, and safety.

This is the centerpiece of the release.

Most ordinary code that used the old collections will continue to work as-is, except as detailed below.

The most important collections changes are:

  • Simpler method signatures
    • No moreCanBuildFrom. Transformation methods no longer take an implicitCanBuildFrom parameter.
    • The resulting library is easier to understand (in code, Scaladoc, and IDE code completion).
    • It also makes user code compile faster.
    • A newBuildFrom implicit is used in a handful of places that need it.
  • Simpler type hierarchy
    • No moreTraversable andTraversableOnce.
      • They remain only as deprecated aliases forIterable andIterableOnce.
    • Parallel collections are now aseparate module.
      • As a result,GenSeq,GenTraversableOnce, et al are gone.
  • Immutablescala.Seq
    • Seq is now an alias forcollection.immutable.Seq
      • Before, it was an alias for the possibly-mutablecollection.Seq.
    • This also changes the type of varargs in methods and pattern matches.
    • Arrays passed as varargs are defensively copied. (#6970)
  • Simplified views that work
  • Alphanumeric method names
    • All symbolic operators are now just aliases for descriptive alphanumeric method names.
    • Examples:++ (alias forconcat),+: (alias forprepended),:+ (alias forappended), and so on.
  • New, fasterHashMap/Set implementations
    • Both immutable (d5ae93e) and mutable (#7348) versions were completely replaced.
    • They substantially outperform the old implementations in most scenarios.
    • The mutable versions now perform on par with the Java standard library's implementations.
  • New concrete collections
  • New abstract collection typeSeqMap

Additional collections changes:

  • Newto(Collection) method
    • Replaces oldto[Collection] method.
    • The argument is the companion object of the desired collection type, for example.to(Vector).
    • The API change enables support for all collection types (includingMap,BitSet, et al).
  • No morecollection.breakOut
    • It requiredCanBuildFrom, which no longer exists.
    • To avoid constructing intermediate collections, use.view and.to(Collection) instead.
  • List andVector are safer
    • They now offer safe publication under the Java Memory Model, usingreleaseFence (#6425)
  • Added in-place operations on mutable collections
    • filterInPlace,mapInPlace,flatMapInPlace, and others.
    • These methods update the original collection in-place, rather than creating a new collection to hold the results.
  • Java interop has moved
    • Extension methods for Scala are now inscala.jdk
    • Explicit converters for Java are inscala.jdk.javaapi
    • The reorganization centralizes all to-and-from-Java converters, including both collection and non-collection types, in a single package.
    • AddedStepper, which is likeIterator but supports efficient unboxed iteration, Java interop. (#7458)
  • Collection serialization has changed
    • Collections now use the serialization proxy pattern uniformly whenever possible. (#6676,#7624,scala-dev#562,sbt/sbt#89)
    • In some classloading environments, notably sbt's non-forked test execution, code changes may be needed.
  • Added.unfold
    • This allows constructing a collection or iterator from an initial element and a repeatedOption-returning operation, terminating onNone.
    • This was added collection companion objects and toIterator (#6851)
  • Added.lengthIs/.sizeIs and.sizeCompare
    • These allow fluent size comparisons without traversing the whole collection (#6950,#6758)
    • Examples:xs.sizeIs < 10,xs.sizeIs == 2
  • Error-proneMap methods deprecated
    • Deprecated.filterKeys and.mapValues (#7014)
    • Instead, use the new methods of the same names onMapView (e.g..view.filterKeys)
  • Added.lazyZip
  • Added.tapEach method
    • This allows inserting side-effects in a chain of method calls on a collection or view. (#7124)
  • Added.updatedWith andupdateWith methods toMaps
    • updatedWith is onimmutable.Map,updateWith is onmutable.Map. (#7320,#7517)
    • These methods allow modifying a map entry based on its current value.
  • Added.maxOption,.minOption,.maxByOption,.minByOption
    • These methods safely handle the empty case. (#6574)
  • Deprecated symbolic methods with multiple arguments
    • Such methods may be disallowed entirely in a future Scala. (#6719)
  • Adding custom collections and operations works very differently
    • See documentation links below.

To learn more about the new APIs and how to adapt your code, consult:

We welcome assistance in continuing to expand and improve these documents.

Concurrency

Futures were internally redesigned, with these goals:

  • provide expected behavior under a broader set of failure conditions
  • provide a foundation for increased performance
  • support more robust applications

Details:

  • Updated and revised ourFuture andPromise implementation. (#6610,#7663)
    • Among other changes, handling ofInterruptedException andRejectedExecutionException is improved.
  • Made the globalExecutionContext “batched”. (#7470)
    • (This change was reverted in Scala 2.13.4. The batched executor is available for opt-in, but will no longer be the default. See the2.13.4 release notes.)
  • Added synchronous ("parasitic")ExecutionContext. (#7784)

Standard library: additions

  • Integrated Java interop (#7987)
    • The oldscala-java8-compat module is now part of the standard library. (#7458)
    • This provides converters for options, function types and Java streams.
    • (As mentioned above, collection converters such asJavaConverters were moved to fit into the new scheme.)
  • new:scala.util.Using
    • This uses the loan pattern to provide a simple form of automatic resource management. (#6907,#7468)
  • new: uses interpolator in pattern matches
    • Provides a simple string matcher as the dual of the simple string interpolator. (#7387)
    • Example:val s"$day-$month-$year" = "11-June-2019"
  • new:pipe andtap
    • These chaining operations are available viaimport scala.util.chaining._. (#7007)
    • Example:3.pipe(_ * 5) evaluates to 15
    • Example:9.tap(println) first prints 9, then returns it
  • new:.toIntOption, et al
    • These new extension methods onString are provided byStringOps.
    • They parse literals and efficiently reject invalid input without throwing exceptions. (#6538)
    • Examples:"12".toIntOption =>Some(12),"12.3".toIntOption =>None,"12.3".toDoubleOption =>Some(12.3)
  • new: namedProduct elements
  • new:.withRight,.withLeft
    • These methods onLeft andRight allow upcasting the other type parameter (#7011,#7080)
    • Example:Left(3).withRight[String] has typeEither[Int, String] without having to writeInt
  • new:Ordering.Double.TotalOrdering,Ordering.Float.TotalOrdering
  • new: converters between functions and extractors
    • New methods provide conversions among optionalFunctions,PartialFunctions and extractor objects. (#7111)
  • new:@unused annotation
    • This annotation is useful for suppressing warnings under-Xlint. (#7623)

Standard library: changes

  • Library fits incompact1 profile
  • Option extendsIterableOnce
    • This improves type inference when calling an overloadedflatMap. (#8038)
  • UndeprecatelinesIterator to avoid conflict with JDK 11'sString.lines (#7269)
  • PartialFunction now overloadsandThen. (#7263)
  • ReplacedCloneable/Serializable traits with type aliases (#6729)
  • ControlThrowable never suppresses (#7413)
  • BigDecimal's handling ofMathContexts has changed (#6884)

Standard library: deprecations and removals

Not a complete list, only the deprecations users are likeliest to encounter.

  • String-building using+ with a non-String type on the left (akaany2stringadd) is deprecated. (#6315,#6755)
  • PartialFunction.fromFunction replacesPartialFunction.apply (#6703)
  • Right projections onEither are deprecated. (#6682,#8012)
  • Deprecated@usecase Scaladoc tag. (#7462)
  • Deprecated universalEquiv. (#7414)
  • The following modules are no longer included in the distribution:scala-xml,scala-parser-combinators,scala-swing.
    • They are community-maintained and published to Maven Central.
  • Assorted deprecated methods and classes throughout the standard library have been removed entirely.

Language changes

2.13 is primarily a library release, not a language/compiler release. Regardless, some language changes are included:

Features:

  • Literal types
    • Literals (for strings, integers, and so on) now have associated literal types. (#5310)
    • See the original proposal,SIP-23, for motivation and details.
    • The compiler will provide instances of a new typeclassscala.ValueOf[T] for all singleton typesT.
    • ASingleton upper bound prevents widening (e.g.T <: Int with Singleton).
    • The value of a singleton type can be accessed by calling methodvalueOf[T]. Example:val one: 1 = valueOf[1]
  • Partial unification on by default
  • By-name implicits with recursive dictionaries
    • This extends by-name method arguments to support implicit (not just explicit) parameters.
    • This enables implicit search to construct recursive values.
    • The flagship use-case is typeclass derivation.
    • Details: see theby-name implicits SIP,#6050,#7368
  • Underscores in numeric literals
    • Underscores can now be used as a spacer. (#6989)
    • Example:1_000_000

Experimental features:

Deprecations:

  • Procedure syntax deprecated
    • Deprecated:def m() { ... } (#6325)
    • Use instead:def m(): Unit = { ... }
  • View bounds deprecated
    • Deprecated:A <% B (#6500)
    • Use instead:(implicit ev: A => B)
  • Symbol literals deprecated
    • Symbols themselves remain supported, only the single-quote syntax is deprecated. (#7395)
    • Library designers may wish to change their APIs to useString instead.
    • Deprecated:'foo
    • Use instead:Symbol("foo")
  • Unicode arrows deprecated
    • In particular, the single arrow operators had the wrong precedence. (#7540)
    • Deprecated:,,
    • Use instead:=>,->,<-
  • postfixOps syntax disabled by default
    • The syntax, already deprecated in 2.12, causes an error in 2.13 unless the feature is explicitly enabled. (#6831)
    • Error:xs size
    • Use instead:xs.size

Adjustments:

  • Imports, including wildcard imports, now shadow locally defined identifiers. (#6589)
  • Underscore is no longer a legal identifier unless backquoted (bug#10384)
    • val _ = is now a pattern match (and discards the value without incurring a warning)
    • implicit val _ = is also now a pattern match (and is useless, because it no longer adds to implicit scope)
  • Don't assume unsound type for ident/literal patterns. (#6502)
    • Matches of the formcase x@N involve callingequals, so it was unsound to typex asN.type.
    • Consider rewriting ascase x:N.type.
  • Make extractor patterns null safe. (#6485)
    • null is treated as no match.
  • Better typing for overloaded higher-order methods (#6871,#7631)
    • This change was a key enabler for the new collections design.
  • Rework unification ofObject andAny in Java/Scala interop (#7966)
  • Name-based pattern matching has changed to enable immutableSeq matches (#7068)
  • Automatic eta-expansion of zero-argument methods is no longer deprecated (#7660)
  • Improve binary stability of extension methods (#7896)
  • Macros must now have explicit return types (#6942)
  • Mixin fields with trait setters are no longer JVM final (#7028)
    • In addition,object fields are now static (#7270)
  • SupportimplicitNotFound on parameters (#6340)
  • Disallow repeated parameters except in method signatures (#7399)
  • Value-discard warnings can be suppressed via type ascription toUnit. (#7563)
  • x op () now parses asx.op(()) notx.op() (#7684)

Compiler

  • Deterministic, reproducible compilation
    • The compiler generates identical output for identical input in more cases, for reproducible builds. (scala-dev#405)
  • Optimizer improvements
    • Operations on collections and arrays are now optimized more, including improved inlining. (#7133)

And:

  • Scaladoc supports setting canonical URLs (#7834)
    • This helps search engines identify the most relevant/recent version of a page when several versions are available.
  • Compiler suggests possible corrections for unrecognized identifiers (#6711)
    • Example:List(1).sizzle =>value sizzle is not a member of List[Int], did you mean size?
  • Added-Yimports for custom preamble imports. (#6764)
    • Example:-Yimports:x,y,z means x, y, and z are root imports of the form:import x._ { import y._ { import z._ { ... } } }
  • The scala-compiler JAR no longer depends on scala-xml (#6436)

Plus, changes to compiler options:

  • Partition options by function:-V for verbose,-W for warnings
    • In general, the old flags still exist as aliases. (#7908)
    • Exceptions (breaking changes) include:
      • Replaced-warn-option with-Woption.
      • Replaced-Xprint:all with-Vprint:_
    • -Werror is now recommended over-Xfatal-warnings.
  • Promoted-deprecation to-Xlint:deprecation (#7714)
  • Deprecated-Xfuture (#7328)
    • Instead, use e.g.-Xsource:2.14
  • Removed-Yno-adapted-args
  • Removed-Xmax-classfile-length
    • It's hard-coded to 240 now (#7497)

Scripting, environment, and integrations

  • The script runner (scala Script.scala) no longer uses thefsc compilation daemon by default. (#6747)
    • The daemon was not reliable and will likely be removed entirely from a future release.
  • JEP 293 style long command-line options are now supported (#6499)
  • The REPL has undergone an internal refactoring to enable future improvements. (#7384)
  • Ant support is no longer bundled. (#6255)

Compiler performance

We invested heavily in compiler speedups during the 2.13 cycle, but most of that work actually already landed in the 2.12.x series, with more to come in 2.12.9.

In addition, compiler performance in 2.13 is 5-10% better compared to 2.12, thanks mainly to the new collections. Seeperformance graph.

Also, certain kinds of code now compile much faster because the compiler aggressively prunes polymorphic implicits during search (#6580).

Migration

Upgrading from 2.12? Enable-Xmigration while upgrading to request migration advice from the compiler.

Compatibility

Like Scala 2.12, the 2.13 series targets Java 8, minimum. Both 2.12 and 2.13 also work on later JDKs such as JDK 11; see ourJDK Compatibility Guide.

Although Scala 2.11, 2.12, and 2.13 are mostly source compatible to facilitate cross-building, they are notbinary compatible. This allows us to keep improving the Scala compiler and standard library.

All 2.13.x releases will be fully binary compatible with 2.13.0, in according withthe policy we have followed since 2.10.

Projects built withsbt must use at least sbt 1.2.8 (or 0.13.18) to use Scala 2.13. To move to 2.13, bump thescalaVersion setting in your existing project.

Scala also works withMaven,Gradle, and other build tools.

Obtaining Scala

Scala releases are available through a variety of channels, including (but not limited to):

  • Bump thescalaVersion setting in your sbt-based project
  • Download a distribution fromscala-lang.org
  • Obtain JARs viaMaven Central
  • Certain package managers (such as homebrew and SDKMAN) offer Scala.

Reporting bugs

Please file any bugs you encounter onour issue tracker. If you aren't yet sure something is a bug, ask onusers.scala-lang.org.

Contributors

A big thank you to everyone who's helped improve Scala by reporting bugs, improving our documentation, kindly helping others on forums and at meetups, and submitting and reviewing pull requests! You are all magnificent.

Scala 2.13.0 is the result of merging over 1500 pull requests.

The pull request queue is managed by the Scala team at Lightbend:Adriaan Moors,Lukas Rytz,Jason Zaugg,Seth Tisue,Stefan Zeiger,Eugene Yokota.

Thanks toLightbend for their continued sponsorship of the Scala core team’s efforts. Lightbend offerscommercial support for Scala.

The new collections API was developed in fruitful collaboration with the Scala Center, with major contributions from the community.

This release was brought to you by 162 contributors, according togit shortlog -sn --no-merges 2.13.x ^2.12.x ^e2a211c. Thank you Julien Richard-Foy, Lukas Rytz, Jason Zaugg, A. P. Marki, Stefan Zeiger, Kenji Yoshida, Adriaan Moors, Josh Lemer, NthPortal, Miles Sabin, Diego E. Alonso-Blas, Seth Tisue, Guillaume Martres, Marcelo Cenerino, Dale Wijnand, Odd Möller, Martin Odersky, Allan Renucci, Georgi Krastev, Eugene Yokota, Harrison Houghton, Martijn Hoekstra, Viktor Klang, Aaron S. Hawley, Ólafur Páll Geirsson, Rex Kerr, hepin1989, Philippus Baalman, Matthew de Detrich, Isaac Levy, exoego, Greg Methvin, Jasper Moeys, Sébastien Doeraene, wholock, Aggelos Biboudis, yui-knk, Matthias Sperl, Xavier Fernández Salas, Ethan Pronovost, Janek Bogucki, awibisono, BuildTools, Mike Skells, Jimin Hsieh, Jonathan Frawley, Xavier GUIHOT, Chris Phelps, chanyong.moon, Cong Zhao, Enno Runne, LPTK, Pathikrit Bhowmick, Yuval Dagan, Li Haoyi, Guillaume Massé, Christopher Hunt, Kamil Kloch, Marco Zühlke, Danila Matveev, Juliusz Sompolski,杨博 (Yang Bo), Masaru Nomura, Benjamin Kurczyk, Vince, taku0, Arnout Engelen, Tim Ruhland, Nicolas Stucki, Nicolas Rinaudo, Stephen Nancekivell, ashwin, Kobenko Mikhail, Song Kun, Anthony Tjuatja, k.bigwheel, ke-to, kelebra, mcintdan, mmocentre, psilospore, roman, svatsan, texasbruce, tim-zh, valydia, veera venky,虎鸣, Adianto Wibisono, Alden Torres, Alejandro Sellero, Alessandro Buggin, Alex Glukhovtsev, Alex Levenson, Alexey-NM, Anatolii, Andrei Baidarov, Andriy Plokhotnyuk, Bakhytzhan Karabalin, Benni, Callum Turnbull, Chris Birchall, Chujie Zeng, Cody Allen, Daniel Dietrich, Daniel Moss, Daniel Slapman, David Barri, David Hoepelman, Denis Buzdalov, Denys Shabalin, Dhanesh, Dhanesh Arole, Edin Dudojević, Eugene Platonov, Faiz Halde, Gabriel Claramunt, Heikki Vesalainen, Iaroslav Zeigerman, Jack Koenig, Jean Michel Rouly, Jeff Brower, Jeff Shaw, Josh, Kazuhiro Sera, Kentaro Tokutomi, Lionel Parreaux, Magnolia.K, Martin Duhem, Michael Steindorfer, Nafer Sanabria, Narek Asadorian, Oleksii Tkachuk, Oscar Boykin, PJ Fanning, Paolo Giarrusso, Pap Lőrinc, Pavel Petlinsky, Peter Fraenkel, Philip, Piotr Kukielka, Qiang Sima, Rob Norris, Robin Stephenson, Rui Gonçalves, Ruud Welling, Ryan McDougall, ShankarShastri, Simão Martins, Sperl Matthias, Sujeet Kausallya Gholap, Uttej Guduru, Vincent de Haan, Vladimir Parfinenko, Vlastimil Dort, Yang Bo, Zizheng Tai, ccjoywang, esarbe, howtonotwin, jvican.

Conclusion

We again thank our contributors and the entire Scala community.

May you find Scala 2.13 a joy to code in!

Assets9
Loading

[8]ページ先頭

©2009-2025 Movatter.jp