Following code compiles fine with Scala 2.13.12, but not with Scala 3.3.1:
import scala.language.implicitConversions
object Types {
trait Vector3f
implicit class Vector3fOps(v: Vector3f) {
def *(rhs: Double): Vector3f = ???
}
}
import Types._
object Compute {
case class Matrix3f(col1: Vector3f, col2: Vector3f, col3: Vector3f) {
def * (x: Double): Vector3f = col1 * x
}
implicit class Vec3Ops(v: Vector3f) {
def * (m: Matrix3f): Vector3f = ???
}
}
The error is:
Found: (x : Double)
Required: Compute.Matrix3f [14:42]
The code compiles fine when I merge the objects Types and Compute into one, when I move the import Types._ into the object Compute or when I remove the Vec3Ops.
It seems Vec3Ops.* somehow hides the Vector3fOps.* for Scala 3 compiler.
Why is this? Is this a bug in Scala 3 compiler, or is there some reason for the new behavior?