Open
Description
Compiler version
3.3.3
Minimized code
sealed trait WIO[+Err, +Out] {
def handleError[Err1,Out1 >: Out, ErrIn >: Err](
f: ErrIn => WIO[Err1, Out1]
): WIO[Err1, Out1] = HandleError(f)
}
case class HandleError[+ErrOut, +Out, ErrIn](handleError: ErrIn => WIO[ErrOut, Out]) extends WIO[ErrOut, Out]
Output
The below output is taken from scastie execution
covariant type Out occurs in contravariant position in type [ErrOut, Out, ErrIn]: (Any => Playground.WIO[Any, Out]) =>
Playground.WIO[Any, Out] of method copy$default$1
Expectation
I believe this is a bug due to the following reason:
- The variance error disappears when
handleError
method is removed. - It compiles in Scala 2.
- The error points to the generated copy method
- I don't see why it would be a contravariant position
Sorry for the poor issue title, I couldn't think of a better one.