Skip to content

variance validation is buggy #7536

Open
@scabug

Description

@scabug

I'm going to fix this.

trait Base[A]

trait Ord1[-A] extends Base[A1 forSome { type A1 >: A }]  // fails
trait Ord2[-A, A1 >: A] extends Base[A1]                  // compiles

trait Ord3[+A] extends Base[A1 forSome { type A1 <: A }]  // fails
trait Ord4[+A, A1 <: A] extends Base[A1]                  // compiles
a.scala:3: error: contravariant type A occurs in invariant position in type [-A]Base[A1 forSome { type A1 >: A }] of trait Ord1
trait Ord1[-A] extends Base[A1 forSome { type A1 >: A }]  // fails
      ^
a.scala:6: error: covariant type A occurs in invariant position in type [+A]Base[A1 forSome { type A1 <: A }] of trait Ord3
trait Ord3[+A] extends Base[A1 forSome { type A1 <: A }]  // fails
      ^
two errors found

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions