-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Labels
4 - In ReviewA fix for the issue is submitted for review.A fix for the issue is submitted for review.Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything feature
Milestone
Description
Version Used:
Visual Studio Community 2022 - 17.14.16
Steps to Reproduce:
- Define the following types:
interface ITree<TV, TNode> where TNode : ITree<TV, TNode>; class Tree<T> : ITree<T, Tree<T>>;
- Create an extension method with two overloads:
static class P { extension<TV, TN>(ITree<TV, TN> node) where TN : ITree<TV, TN> { public void Add(TV value) { } public void Add(params TV[] values) { } } }
- Try to call
Add
with a single argument:Tree<int> b = new Tree<int>(); b.Add(1); // CS0121: Ambiguous call between 'Add(TV)' and 'Add(params TV[])'
Expected Behavior:
The compiler should resolve b.Add(1)
to the non-params
overload (Add(TV)
), since it has a fixed number of arguments.
Actual Behavior:
Compiler error CS0121 occurs, indicating ambiguity between Add(TV)
and Add(params TV[])
.
Diagnostic Id:
CS0121 (The call is ambiguous between the following methods or properties)
Metadata
Metadata
Assignees
Labels
4 - In ReviewA fix for the issue is submitted for review.A fix for the issue is submitted for review.Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything feature