scala-collection-compat


License

License

Categories

Categories

Scala Languages
GroupId

GroupId

org.scala-lang.modules
ArtifactId

ArtifactId

scala-collection-compat_sjs0.6_2.13
Last Version

Last Version

2.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

scala-collection-compat
scala-collection-compat
Project URL

Project URL

http://www.scala-lang.org/
Project Organization

Project Organization

org.scala-lang.modules
Source Code Management

Source Code Management

https://github.com/scala/scala-collection-compat

Download scala-collection-compat_sjs0.6_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/org.scala-lang.modules/scala-collection-compat_sjs0.6_2.13/ -->
<dependency>
    <groupId>org.scala-lang.modules</groupId>
    <artifactId>scala-collection-compat_sjs0.6_2.13</artifactId>
    <version>2.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.scala-lang.modules/scala-collection-compat_sjs0.6_2.13/
implementation 'org.scala-lang.modules:scala-collection-compat_sjs0.6_2.13:2.2.0'
// https://jarcasting.com/artifacts/org.scala-lang.modules/scala-collection-compat_sjs0.6_2.13/
implementation ("org.scala-lang.modules:scala-collection-compat_sjs0.6_2.13:2.2.0")
'org.scala-lang.modules:scala-collection-compat_sjs0.6_2.13:jar:2.2.0'
<dependency org="org.scala-lang.modules" name="scala-collection-compat_sjs0.6_2.13" rev="2.2.0">
  <artifact name="scala-collection-compat_sjs0.6_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.scala-lang.modules', module='scala-collection-compat_sjs0.6_2.13', version='2.2.0')
)
libraryDependencies += "org.scala-lang.modules" % "scala-collection-compat_sjs0.6_2.13" % "2.2.0"
[org.scala-lang.modules/scala-collection-compat_sjs0.6_2.13 "2.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.3
org.scala-js : scalajs-library_2.13 jar 0.6.33

test (2)

Group / Artifact Type Version
org.scala-js : scalajs-test-bridge_2.13 jar 0.6.33
org.scala-js : scalajs-junit-test-runtime_2.13 jar 0.6.33

Project Modules

There are no modules declared in this project.

Build Status

Purpose and scope

This library makes some Scala 2.13 APIs available on Scala 2.11 and 2.12.

The idea is to facilitate cross-building Scala 2.13 code on the older versions.

Although the name of the library is scala-"collection"-compat, we have now widened the scope to include other parts of the Scala 2.13 standard library besides just collections.

Only the most commonly used APIs are supported; many are missing. Contributions are welcome.

Usage

To use this library, add the following to your build.sbt:

libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.0"

All future versions will remain backwards binary compatible with 2.0.0. (The 1.0.0 release was withdrawn and should not be used.)

How it works

The 2.13 collections redesign did not break source compatibility for most ordinary code, but there are some exceptions.

For example, the to method is used with a type parameter in 2.12:

xs.to[List]

With this compatibility library you can instead use the 2.13 syntax, which takes a value parameter:

import scala.collection.compat._
xs.to(List)

The 2.13 version consists only of an empty scala.collection.compat package object that allows you to write import scala.collection.compat._ in 2.13.

The 2.11 and 2.12 versions have the needed compatibility code in this package.

The library also adds backported versions of new collection types, such as immutable.ArraySeq and immutable.LazyList. (On 2.13, these types are just aliases to standard library types.)

And it adds backported versions of some 2.13 collections methods such as maxOption.

And, it includes support for some non-collections classes such as the @nowarn annotation added in 2.13.2.

Migration rules

The migration rules use scalafix. Please see the official installation instructions and, in particular, check that your full Scala version is supported (ex 2.12.12).

// project/plugins.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.19")

Collection213Upgrade

The Collection213Upgrade rewrite upgrades to the 2.13 collections without the ability to compile the code-base with 2.12 or 2.11. This rewrite is suitable for applications that don't need to cross-compile against multiple Scala versions.

// build.sbt
scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % "2.3.0"
addCompilerPlugin(scalafixSemanticdb)
scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on")
// sbt shell
> ;test:scalafix Collection213Upgrade ;scalafix Collection213Upgrade

Collection213CrossCompat

The Collection213CrossCompat rewrite upgrades to the 2.13 collections with the ability to compile the code-base with 2.12 or later. This rewrite is suitable for libraries that are cross-published for multiple Scala versions.

To cross-build for 2.12 and 2.11, the rewrite rule introduces a dependency on the scala-collection-compat module, which provides the syntax of 2.13 on 2.12 and 2.11. This enables you to write your library using the latest 2.13 collections API while still supporting users on an older Scala version.

// build.sbt
scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % "2.3.0"
libraryDependencies +=  "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.0"
addCompilerPlugin(scalafixSemanticdb)
scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on")
// sbt shell
> ;test:scalafix Collection213CrossCompat ;scalafix Collection213CrossCompat

Build.scala

// If you are using project/Build.scala add the following imports:
import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixDependencies, scalafixSemanticdb}

Contributing

The migration tool is not exhaustive. Contributions of additional rewrites are welcome. If you encounter a use case that’s not supported, please report it as described in the contributing documentation.

org.scala-lang.modules

The Scala Programming Language

Versions

Version
2.2.0
2.1.6
2.1.5
2.1.4
2.1.3
2.1.3-RC3
2.1.3-RC2
2.1.2
2.1.1
2.1.0
2.0.0