Enabling implicit conversions

Consider these two packages:

package foo
given StringIntConversion: Conversion[String, Int] = _.toInt
package bar
import foo.StringIntConversion
val n: Int = "42"

The -feature option of the compiler produces a warning in both packages foo and bar. I would expect a warning in foo but not in bar.

The compiler also adds: See the Scala docs for value scala.language.implicitConversions for a discussion. The scaladoc (API) is silent, but an older documentation page on implicit conversions states:

To turn off the warnings take either of these actions:

- Import scala.language.implicitConversions into the scope of the implicit conversion definition
- Invoke the compiler with -language:implicitConversions

No warning is emitted when the conversion is applied by the compiler.

That doesn’t seem consistent with the observed behavior.

1 Like

I have a perhaps related issue in that when I apply -feature and -language:implicitConversions flags across multiple projects via ThisBuild, then I see above referenced warnings around implicit conversions in dependent projects of the base project where ThisBuild is applied.

If I then add the -language:implicitConversions flag to each project’s build I then get “X flag applied repeatedly” (since each project already inherits the flag via ThisBuild).

At any rate it’s a bit annoying seeing spurious warnings everywhere.