Closed
Description
The code below compiles with scalac 2.12, but not with dotty
trait Foo {
type State
def bar(f: Bar[State] => Bar[State]): Foo = this
}
object Foo {
def unit: Foo = new Foo {
type State = Any
}
def doBar: Foo = unit.bar(bar => bar)
}
case class Bar[+A]()
Code like this will produce following compilation error:
[error] 17 | identity.bar(bar => bar)
[error] | ^^^
[error] | Found: scalaz.zio.test.Bar[scalaz.zio.test.Foo#State](bar)
[error] | Required: scalaz.zio.test.Bar[Nothing]
[error] one error found
If we change the declaration of Bar to case class Bar[A]()
(got rid of covariance) we will get another error:
[error] 16 | def doBar: Foo = unit.bar(bar => bar)
[error] | ^^^
[error] | Found: scalaz.zio.test.Bar[_](bar)
[error] | Required: Nothing
[error] one error found
If we change unit
to be a val
instead of def
it compiles, but this is just a distilled, minimum code that produces the same error as we encountered during scalaz-zio compilation with dotty 0.13.0-RC1
, see related ticket zio/zio#702