-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
C# compiler chooses inaccessible extension method over accessible one #25813
Comments
Should be something to be improved as part of dotnet/csharplang#98 @gafter It doesn't seem like this is part of those improvements. Is this perhaps a regression? If not, can this still be added as part of the improved overload resolution? |
|
VS2015 behaves exactly the same way. |
Looks like a bug. Inaccessible members should not affect overload resolution. |
See https://github.com/dotnet/csharplang/blob/master/spec/expressions.md#extension-method-invocations . In the terminology of the spec, we are letting non-eligible candidates short-circuit finding the right method group. |
In review in #26345 |
Version Used:
Microsoft (R) Visual C# Compiler version 2.6.0.62329 (5429b35)
Steps to Reproduce:
Program.cs
:Expected Behavior:
Project compiled successfully.
System.Linq.Enumerable.Contains()
used as an argument ofSystem.Linq.Enumerable.Count()
function.Actual Behavior:
Compiler error CS0122: 'Extensions.Contains(IEnumerable, T)' is inaccessible due to its protection level
Original case is described in C# compiler chooses wrong extension method question on StackOverflow. CS0122 wrong member inaccessible when overload does not exist issue looks related.
The text was updated successfully, but these errors were encountered: