Skip to content

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

@cston

Description

@cston

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions