Ignore unused-imports for scala.collection.compat

Problem: It’s difficult to use import scala.collection.compat._ in conjunction with fatal-warnings and -Wunused-imports as the Scala 2.13 code is likely to not use the compat import.

There was a PR created to make scala.collection.compat a special case, but it hasn’t been merged:

I don’t think we can use @nowarn or -Wconf to help unfortunately. Some commentary on exploring that avenue is available available here.


Ultimately it would be nice to construct scalac options such the following code compiled without warnings:

package scala.collection {
  package object compat
}

package here.is.a.test {
  import scala.collection.compat._           // no warning
}

e.g. we are able to ignore the unused warning on a particular import
But, with the same settings have the following code warn on the ListBuffer import:

package scala.collection {
  package object compat
}

package here.is.a.test {
  import scala.collection.compat._           // no warning
  import scala.collection.mutable.ListBuffer // warning
}

This came up in trying to adopt scala-collection-compat in http4s.

I think I (and many others) had similar issues with scala-parallel-collections. This solution worked for us:

Maybe it (or something like that) will work for you with scala-collection-compat :wink: