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
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.
12
+
13
+
Only the most commonly used APIs are supported; many are missing. Contributions are welcome.
14
+
15
+
## Usage
16
+
17
+
To use this library, add the following to your `build.sbt`:
Version 2.0.0+ is compatible with Scala 2.13, 2.12, and 2.11.
23
+
Exception: the 1.0.0 release was withdrawn and should not be used.
15
24
16
-
Note that there are multiple ways to cross-build projects, see https://github.com/scala/collection-strawman/wiki/FAQ#how-do-i-cross-build-my-project-against-scala-212-and-scala-213.
25
+
All future versions will remain backwards binary compatible with 2.0.0+.
17
26
18
-
**Note**: Please do not release any artifacts against version 1.0.0, due to [#195](https://github.com/scala/scala-collection-compat/issues/195).
27
+
## How it works
19
28
20
-
Backwards binary compatibility will be enforced within each major version (i.e. all 1.x.y releases will be binary compatible).
29
+
The 2.13 collections redesign did not break source compatibility for much ordinary code, there are exceptions.
21
30
22
-
The 2.13 collections are mostly backwards source-compatible, but there are some exceptions. For example, the `to` method is used with a type parameter in 2.12:
31
+
For example, the `to` method is used with a type parameter in 2.12:
23
32
24
33
```scala
25
-
xs.to[List]
34
+
xs.to[List]
26
35
```
27
36
28
-
With this compatibility library you can also use the 2.13 syntax which uses a companion object:
37
+
With this compatibility library you can instead use the 2.13 syntax, which takes a value parameter:
29
38
30
39
```scala
31
-
importscala.collection.compat._
32
-
xs.to(List)
40
+
importscala.collection.compat._
41
+
xs.to(List)
33
42
```
34
43
35
44
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.
36
-
The 2.11/2.12 version has the compatibility extensions in this package.
37
45
38
-
The library also adds backported versions of new collection types, currently `scala.collection.compat.immutable.ArraySeq`. In 2.11/2.12, this type is a new collection implementation. In 2.13, it is an alias for `scala.collection.immutable.ArraySeq`.
46
+
The 2.11 and 2.12 versions have the needed compatibility code in this package.
39
47
40
-
## Migration Tool
48
+
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.)
41
49
42
-
The migration rules use scalafix. Please see the [official installation instruction](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your full Scala version is supported (ex 2.12.12).
50
+
And it adds backported versions of some 2.13 collections methods such as `maxOption`.
51
+
52
+
And, it includes support for some non-collections classes such as the `@nowarn` annotation added in 2.13.2.
53
+
54
+
## Migration rules
55
+
56
+
The migration rules use scalafix. Please see the [official installation instructions](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your full Scala version is supported (ex 2.12.12).
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.
69
82
70
83
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.
0 commit comments