Skip to content

Add support for variance safety for static interface members #1343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: draft-v9
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions standard/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ If a generic interface is declared in multiple parts ([§15.2.3](classes.md#1523

#### 18.2.3.2 Variance safety

The occurrence of variance annotations in the type parameter list of a type restricts the places where types can occur within the type declaration.
The occurrence of variance annotations in the type parameter list of a type restricts the places where types can occur within the type declaration. However, these restrictions do not apply to occurrences of types within a declaration of a static member.

A type T is ***output-unsafe*** if one of the following holds:
A type `T` is ***output-unsafe*** if one of the following holds:

- `T` is a contravariant type parameter
- `T` is an array type with an output-unsafe element type
- `T` is an interface or delegate type `Sᵢ,... Aₑ` constructed from a generic type `S<Xᵢ, ... Xₑ>` where for at least one `Aᵢ` one of the following holds:
- `Xᵢ` is covariant or invariant and `Aᵢ` is output-unsafe.
- `Xᵢ` is contravariant or invariant and `Aᵢ` is input-unsafe.

A type T is ***input-unsafe*** if one of the following holds:
A type `T` is ***input-unsafe*** if one of the following holds:

- `T` is a covariant type parameter
- `T` is an array type with an input-unsafe element type
- `T` is an interface or delegate type `S<Aᵢ,... Aₑ>` constructed from a generic type `S<Xᵢ, ... Xₑ>` where for at least one `Aᵢ` one of the following holds:
- `T` is an interface or delegate type `S<Aᵢ,... Aₑ>` constructed from a generic type `S<Xᵢ, ... Xₑ>` where for at least one `Aᵢ` one of the following holds:
- `Xᵢ` is covariant or invariant and `Aᵢ` is input-unsafe.
- `Xᵢ` is contravariant or invariant and `Aᵢ` is output-unsafe.

Expand Down