Skip to content

Suggested import is not always helpful when suggestion is too generic #24418

@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.7.4, 3.8.0-RC1-bin-20251113-8b5d445-NIGHTLY

Minimized example

$ cat suggested_import.scala 
import scala.deriving.Mirror

object test {
  object Generic:
    given fromMirror[M <: Mirror](using m: M): M = ???
  trait TC[A]

  summon[TC[Int]]
}

Output Error/Warning message

$ scala-cli -S 3.nightly suggested_import.scala 
Compiling project (Scala 3.8.0-RC1-bin-20251113-8b5d445-NIGHTLY, JVM (21))
[error] ./suggested_import.scala:8:18
[error] No given instance of type test.TC[Int] was found for parameter x of method summon in object Predef
[error] 
[error] The following import might make progress towards fixing the problem:
[error] 
[error]   import test.Generic.fromMirror
[error] 
[error]   summon[TC[Int]]
[error]                  ^

Why this Error/Warning was not helpful

The message was unhelpful because importing fromMirror will not help.

Suggested improvement

It could be made more helpful by not suggesting anything. In the provided code there is not import that will help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions