Skip to content

readme tweaks #680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
[![scala-collection-compat Scala version support](https://index.scala-lang.org/scala/scala-collection-compat/scala-collection-compat/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/scala/scala-collection-compat/scala-collection-compat)

## 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](https://github.com/scala/collection-strawman/wiki/FAQ#how-do-i-cross-build-my-project-against-scala-212-and-scala-213)
Scala 2.13 and 3.0 code on the older versions.
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/3.0 standard library besides just collections.
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`:
This library is available on the JVM, Scala.js, and Scala Native.

```
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "<version>"
```
| tool | coordinates |
|:---------------:|:------------:|
| sbt | `"org.scala-lang.modules" %% "scala-collection-compat" % "<version>"` |
| scala-cli, mill | `org.scala-lang.modules::scala-collection-compat:<version>` |

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 and 3.0 versions consist only of an empty `scala.collection.compat` package object, so `import scala.collection.compat._` won't cause an error in cross-compiled code.
The Scala 2.13 and Scala 3 versions consist only of an empty `scala.collection.compat` package object, so `import scala.collection.compat._` won't cause an error in cross-compiled code.

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

Expand Down Expand Up @@ -109,9 +108,10 @@ scalacOptions += "-P:semanticdb:synthetics:on"
```

### Fixing unused import warnings

In Scala 2.13 the `import scala.collection.compat._` sometimes is not needed (e.g. `.to(SeqType)` is natively available).
This leads to a `unused import` warning under Scala 2.13 even though the import is required for Scala 2.12.
In order to work around this, you can pass a compiler option to ignore this specific issue, e.g. in SBT:
In order to work around this, you can pass a compiler option to ignore this specific issue, e.g. in sbt:
```scala
scalacOptions += "-Wconf:origin=scala.collection.compat.*:s"
```
Expand Down
Loading