Skip to content

Unsoundness due to missing variance checks for extends clause #2973

Closed
@smarter

Description

@smarter

This shouldn't compile:

class Foo[T]
class Bar[-T] extends Foo[T]

scalac realises that:

error: contravariant type T occurs in invariant position in type [-T]Foo[T] {
  def <init>(): Bar[T]
} of class Bar
class Bar[-T] extends Foo[T]
      ^
one error found

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions