Issue with generic types

I do not understand why the following code does not compile.

sealed trait IntT
sealed trait NatT extends IntT
final class _0(v: Nothing) extends NatT
final class Succ[N <: NatT](v: Nothing) extends NatT
final class Minus[N <: Succ[NatT]](v: Nothing) extends IntT
type minus1 = Minus[Succ[_0]]

Here is the error I get:

Type argument Succ[_0] does not conform to upper bound Succ[NatT]
type minus1 = Minus[Succ[_0]]

I’m using Scala 3.1.3.

You want to declare those as covariant.

1 Like

Ah, of course. Thanks!