scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

unusual error message package object implicits #12967

Closed xuwei-k closed 6 months ago

xuwei-k commented 6 months ago

Reproduction steps

Scala version: 2.13.13

build.sbt

scalaVersion := "2.13.13"

scalacOptions += "-Xsource:3"

A.scala

package a1

package object a2 {
  implicit def myClassToSeq[A](a: MyClass[A]): Seq[A] = a.values
}

package a2 {
  case class MyClass[A](values: Seq[A])
}

object Main {
  def f[A](x: Seq[a1.a2.MyClass[A]]): Seq[A] = x.flatten
}

Problem

A.scala:12:50: Implicit value $anonfun was found in a package prefix of the required type, which is not part of the implicit scope in Scala 3.
[error] For migration, add `import a1.Main.$anonfun`.
[error] Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=a1.Main.f
[error]   def f[A](x: Seq[a1.a2.MyClass[A]]): Seq[A] = x.flatten
[error]                                                  ^