Scala 3 handles using
vs implicit
in different ways:
trait Dummy
def foo(i: Int)(implicit d: Dummy): String => String = _ * i
def bar(i: Int)(using Dummy): String => String = _ * i
given Dummy = new Dummy {}
foo(5)("test") // Fails with Found: ("test" : String) Required: Dummy
bar(5)("test")
I assume this is by design to ease migration from 2.13.
I suggest the following changes under -source:future -deprecation
:
- Scala 3 code using
implicit
should emit a deprecation warning. - Scala 3 code using 2.13 code (from a library) which still uses
implicit
should behave as ifusing
was used. Keeping with the example above: assume the methodfoo
was defined in the 2.13 library, the callfoo(5)("test")
in Scala 3 should work (just likebar
).
Without these changes two migrations (of the use of the library in Scala 3) are required:
- While the library is using
implicit
usages likefoo(5)("test")
must be worked around. - Then when the library evolves to
using
those workarounds can, finally, be removed.
Users like me which don’t like to go through the extra hassle of “migrating twice” can jump straight to the “end code” simply by using -source:future
.
Cross-compiling should remain unaffected since it is very unlikely to be compiling the code under -source:future
.