Skip to content

Commit cc9b455

Browse files
committed
scala.IndexedSeq too
1 parent 2b4de2d commit cc9b455

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

_overviews/core/collections-migration-213.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ For an in-depth overview of the Scala 2.13 collections library, see the [collect
1111

1212
The most important changes in the Scala 2.13 collections library are:
1313
- `scala.Seq[+A]` is now an alias for `scala.collection.immutable.Seq[A]` (instead of `scala.collection.Seq[A]`). Note that this also changes the type of Scala varargs methods.
14+
- `scala.IndexedSeq[+A]` is now an alias for `scala.collection.immutable.IndexedSeq[A]` (instead of `scala.collection.IndexedSeq[A]`).
1415
- Transformation methods no longer have an implicit `CanBuildFrom` parameter. This makes the library easier to understand (in source code, Scaladoc, and IDE code completion). It also makes compiling user code more efficient.
1516
- The type hierarchy is simplified. `Traversable` no longer exists, only `Iterable`.
1617
- The `to[Collection]` method was replaced by the `to(Collection)` method.
@@ -30,11 +31,11 @@ The [scala-collection-compat](https://github.com/scala/scala-collection-compat)
3031

3132
The module also provides [migratrion rules](https://github.com/scala/scala-collection-compat#migration-tool) for [scalafix](https://scalacenter.github.io/scalafix/docs/users/installation.html) that can update a project's source code to work with the 2.13 collections library.
3233

33-
## scala.Seq migration
34+
## scala.Seq and scala.IndexedSeq migration
3435

35-
In Scala 2.13 `scala.Seq[+A]` is an alias for `scala.collection.immutable.Seq[A]` ("ISeq"), instead of `scala.collection.Seq[A]` ("CSeq"). This change requires some planning depending on how your code is going to be used.
36+
In Scala 2.13 `scala.Seq[+A]` is an alias for `scala.collection.immutable.Seq[A]` ("ISeq"), instead of `scala.collection.Seq[A]` ("CSeq"). Similarly, `scala.IndexedSeq[+A]` is an alias for `scala.collection.immutable.IndexedSeq[A]`. These changes require some planning depending on how your code is going to be used.
3637

37-
If you're making a library intended to be used by other programmers, then using `scala.Seq` or varargs is going to be a breaking change in the API semantics. For example, if there was a function `def orderFood(order: Seq[Order]): Seq[Food]`, previously the library user would have been able to pass in an array of `Order`, but it won't work for 2.13.
38+
If you're making a library intended to be used by other programmers, then using `scala.Seq`, `scala.IndexedSeq`, or vararg is going to be a breaking change in the API semantics. For example, if there was a function `def orderFood(order: Seq[Order]): Seq[Food]`, previously the library user would have been able to pass in an array of `Order`, but it won't work for 2.13.
3839

3940
- if you cross build with Scala 2.12 and want to maintain the API semantics for 2.13 version of your library, or
4041
- if your library users frequently uses mutable collections such as `Array`
@@ -105,6 +106,17 @@ import scala.annotation.compileTimeOnly
105106
* This Seq trait is a dummy type to prevent the use of `Seq`.
106107
*/
107108
@compileTimeOnly("Use ISeq or CSeq") private[example] trait Seq[A1, F1[A2], A3]
109+
110+
/**
111+
* In Scala 2.13, scala.IndexedSeq moved from scala.collection.IndexedSeq to scala.collection.immutable.IndexedSeq.
112+
* In this code base, we'll require you to name ISeq or CSeq.
113+
*
114+
* import scala.collection.{ IndexedSeq => CIndexedSeq }
115+
* import scala.collection.immutable.{ IndexedSeq => IIndexedSeq }
116+
*
117+
* This IndexedSeq trait is a dummy type to prevent the use of `IndexedSeq`.
118+
*/
119+
@compileTimeOnly("Use IIndexedSeq or CIndexedSeq") private[example] trait IndexedSeq[A1, F1[A2], A3]
108120
~~~
109121

110122
This might be useful during the transition period where you have to remember to import CSeq.

0 commit comments

Comments
 (0)