Open dzanot opened 1 year ago
We need to minimize this example to not have a dependency on cats.effect.IO
.
Here is a zero dependency repro: https://scastie.scala-lang.org/PKqpEimLRYOWZmbl72myFw
@nicolasstucki does this need more information?
Tested with 3.3.0
release, updated the repro
Further minimization:
type IO[T] = T
opaque type NonNegLong = Long
object NonNegLong {
def apply(l: Long): NonNegLong = l
}
class Baz(value: NonNegLong) extends AnyVal
trait InnerThing[F[_]] {
def withBaz(baz: Baz): F[Unit]
}
class InnerThingImpl extends InnerThing[IO] {
override def withBaz(baz: Baz): IO[Unit] = println("withBaz")
}
object Test {
def main(args: Array[String]): Unit = {
val testInnerImpl: InnerThing[IO] = new InnerThingImpl
println("Hello")
val nnl = new Baz(NonNegLong(1L))
testInnerImpl.withBaz(nnl)
println("Goodbye")
}
}
F[Unit]
by Any
and IO[Unit]
by Unit
makes it work.: InnerThing[IO]
makes it work (because InnerThingImpl
gets inferred and therefore we directly call its more specific withBaz
).NonNegLong
a non-opaque type alias makes it work.Baz
a non-AnyVal
makes it work.
Compiler version
3.3.0
Minimized code
https://scastie.scala-lang.org/B5fP4EPnSJeMRIsI84IeQQ
Output
With excaption
Expectation
No
AbstractMethodError
. This works as expected if you do any one of:extends AnyVal
: https://scastie.scala-lang.org/5HMeaYKDQACRXp3r3LomlQF[_]
parameter: https://scastie.scala-lang.org/YDBOeM5zQ3WjUK36mvCPOg