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.