dotnet / dotnet/csharpstandard
Extension methods and Color Color
- Dominant language
- C#
- Stars
- 815
- Forks
- 99
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 16
Description
[The specification says this about the `Color Color` situation:](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/expressions#11762-identical-simple-names-and-type-names)
> The member lookup of `E.I` is never ambiguous, since `I` shall necessarily be a member of the type `E` in both cases. In other words, the rule simply permits access to the static members and nested types of `E` where a compile-time error would otherwise have occurred.
This is technically not correct, since `I` could also be an *extension method* on `E`. [The usual rules](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/expressions#11761-general) of only considering extension methods last avoid any ambiguity, but I think the text should still be clarified.
Note that [the compiler already does the right thing here](https://sharplab.io/#v2:C4LgbgpgTglgZgTwD4AEBMACAwgWAFADe+GJ2A9gDZlTlVQDcxpTJKALBgLIAUAlCxiJ5SI2tQB0AST70MAejkYYAOwDOwAIbKAxhAEislCQGUZ8xSgCMANn2lDdcQFEzCjBAAewCGphllAgC++MF4+OpQAK7awGJQ+EIiKADMGOwY0ryCoUmpVtZpHKZZBKGh+PlpmE5eCQIpaTaFGdzAABYwqnEY2iU5pA2V6abtnd292fV5Tekuo10O1D19IUA===).
Contributor guide
Assessment
This issue has not been assessed yet.