Skip to content
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

Type inference with method groups does not support variance for signatures with ref parameters #55909

Open
cston opened this issue Aug 26, 2021 · 1 comment

Comments

@cston
Copy link
Member

cston commented Aug 26, 2021

Compile:

class Program
{
    static void F1<T>(T t, object o) { }
    static void F2<T>(T t, ref object o) { }

    static void Main()
    {
        _ = new[] { F1<object>, F1<string> }; // ok
        _ = new[] { F2<object>, F2<string> }; // error CS0826: No best type found for implicitly-typed array
    }
}

Expected: Compiler infers a common delegate signature void *(object, ref object) for the second array.

Actual: (9,13): error CS0826: No best type found for implicitly-typed array

Relates to test plan #52192

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 26, 2021
@cston cston self-assigned this Sep 2, 2021
@cston cston added this to the 17.0 milestone Sep 2, 2021
@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 9, 2021
@cston
Copy link
Member Author

cston commented Sep 29, 2021

The type parameters for synthesized delegate types should have in variance for parameters passed by value and out variance for out parameters and return type.

@cston cston modified the milestones: 17.0, 17.1 Sep 29, 2021
@cston cston modified the milestones: 17.1, C# 11.0 Feb 17, 2022
@jaredpar jaredpar modified the milestones: C# 11.0, 17.4 Jun 24, 2022
@jaredpar jaredpar modified the milestones: 17.4, C# 12.0 Jul 20, 2022
@jaredpar jaredpar modified the milestones: C# 12.0, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants