scala/scala3

confusing `Implicit parameters should be provided with a using clause` message if implicit default param

Closed this issue · 2 comments

Compiler version

3.7.0-RC1-bin-20250207-d60a914-NIGHTLY

Minimized example

a1/src/main/scala/A1.scala

object A1 {
  def f1(implicit x1: String, x2: Int = 2): Unit = ()
}

a2/src/main/scala/A2.scala

object A2 {
  given String = "s"

  def f2 = A1.f1
}

build.sbt

val a1 = project.settings(
  scalaVersion := "2.13.16"
)

val a2 = project.settings(
  scalaVersion := "3.7.0-RC1-bin-20250207-d60a914-NIGHTLY"
).dependsOn(a1)

Output Error/Warning message

[warn] -- Warning: example-implicit-using-default-project/a2/src/main/scala/A2.scala:4:16 
[warn] 4 |  def f2 = A1.f1
[warn]   |                ^
[warn]   |Implicit parameters should be provided with a `using` clause.
[warn]   |This code can be rewritten automatically under -rewrite -source 3.7-migration.
[warn]   |To disable the warning, please use the following option: 
[warn]   |  "-Wconf:msg=Implicit parameters should be provided with a `using` clause:s"
[warn] one warning found

Why this Error/Warning was not helpful

This is implicit params but not call with explicit.

Suggested improvement

Note

unnecessary Scala 2 cross build. here is more simple example

Welcome to Scala 3.7.0-RC1-bin-20250207-d60a914-NIGHTLY-git-d60a914 (21.0.6, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                                                        
scala> def f1(implicit x1: String, x2: Int = 2): Unit = ()
def f1(implicit x1: String, x2: Int): Unit
                                                                                                                                                                                                                        
scala> given String = "s"
lazy val given_String: String
                                                                                                                                                                                                                        
scala> f1
1 warning found
-- Warning: --------------------------------------------------------------------
1 |f1
  |  ^
  |Implicit parameters should be provided with a `using` clause.
  |To disable the warning, please use the following option: 
  |  "-Wconf:msg=Implicit parameters should be provided with a `using` clause:s"

Actually this is fixed by #22458

The message is on 3.nightly 2f639e2 but not when I cherry-pick c37dc8b