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

Overload resolution error with indexers across assemblies #46549

Closed
jaredpar opened this issue Aug 4, 2020 · 0 comments · Fixed by #46556
Closed

Overload resolution error with indexers across assemblies #46549

jaredpar opened this issue Aug 4, 2020 · 0 comments · Fixed by #46556
Assignees
Milestone

Comments

@jaredpar
Copy link
Member

jaredpar commented Aug 4, 2020

Repro code

    // lib1.cs 
    public abstract class TaskInput<TKey, TValue>
        where TKey : class
        where TValue : class
    {
        public virtual TValue this[TKey key] => throw null;
    }

    // lib2.cs
    public class CallNode { }
    public sealed class CalleeCallNodeInput<TValue> : TaskInput<CallNode, TValue>
        where TValue : class
    {
        public override TValue this[CallNode key] => throw null;
    }

    // data.cs
    class FunctionSummary { }

    class Repro
    {
        void M()
        {
            CalleeCallNodeInput<FunctionSummary> c = null;
            CallNode node = null;
            var summary = c[node];
        }

        static void Main(){ }
    }

Repro steps:

> csc lib1.cs /t:library
> csc lib2.cs /t:library /r:lib1.dll
> csc data.cs /r:lib1.dll /r:lib2.dll


data.cs(10,27): error CS0121: The call is ambiguous between the following methods or properties: 'TaskInput<TKey, TValue>.this[TKey]' and 'TaskInput<TKey, TValue>.this[TKey]'

This should compile without error or warnings. Likely this is a regession from covariant returns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants