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

Conversation

RexJaeschke
Copy link
Contributor

I just discovered this V9 feature spec here. To make sure this was actually implemented in V9, I compiled the following code:

using System;
using System.Threading.Tasks;

public interface I<out T>
{
    static Task<T> F = Task.FromResult(default(T)); // No problem
    static Task<T> P => Task.FromResult(default(T));   //CS8904 in V8 but OK in V9
    static Task<T> M() => Task.FromResult(default(T));    //CS8904 in V8 but OK in V9
    static event EventHandler<T>? E; // CS8904 in V8 but OK in V9
}

The errors produced by V8 do not occur in V9.

@RexJaeschke RexJaeschke added this to the C# 9.0 milestone Jun 9, 2025
@RexJaeschke RexJaeschke added the type: feature This issue describes a new feature label Jun 9, 2025
@RexJaeschke RexJaeschke marked this pull request as draft June 9, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature This issue describes a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant