Closed
Description
Compiler version
3.1.1
, ... , 3.1.3
, 3.2.0-RC1
, 3.2.1-RC1-bin-20220711-6efd92d-NIGHTLY
Minimized code
trait Functor[F[_]]:
extension [A](fa: F[A])
def void: F[Unit] = ???
given Functor[Option] with {}
given [F[_], X]: Functor[[T] =>> F[X]] with {}
def main =
val o: Option[Int] = ???
o.void
Output
[error] ./main.scala:13:3: Found: (o : Option[Int])
[error] Required: ?{ void: ? }
[error] Note that implicit extension methods cannot be applied because they are ambiguous;
[error] both object given_Functor_Option and given instance given_Functor_F provide an extension method `void` on (o : Option[Int])
[error] o.void
[error] ^
Expectation
Should possibly resolve the method from given_Functor_Option
.
Interestingly, the following code compiles correctly and resolves the method from given_Functor_Option
. (moving the extension method outside of the type class declaration and adding an implicit constraint instead)
trait Functor[F[_]]
extension [F[_]: Functor, A](fa: F[A])
def void: F[Unit] = ???
given Functor[Option] with {}
given [F[_], X]: Functor[[T] =>> F[X]] with {}
def main =
val o: Option[Int] = ???
o.void
Found in #15647
Metadata
Metadata
Assignees
Labels
No labels