-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Extensions: address some follow-ups related to using directives
#79890
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
Conversation
| internal void GetExtensionContainers(ArrayBuilder<NamedTypeSymbol> extensions) | ||
| { | ||
| // Consider whether IsClassType could be used instead. Tracked by https://github.com/dotnet/roslyn/issues/78275 | ||
| if (!IsReferenceType || !IsStatic || IsGenericType || !MightContainExtensionMethods) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check !IsReferenceType || !IsStatic || IsGenericType inside MightContainExtensionMethods instead? #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would make sense.
As part of this PR, I'd identified a couple other questions/follow-ups regarding MightContainExtensionMethods. I captured them to this follow-up issue and captured your suggestion there as well.
I prefer to keep this PR very focused and keep this moved code as-is for now. I'll take a stab at this in next PR, as it's bothering me too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked around a bit and it's already clear the answer is not obvious, so would rather not open a possible can of worms. See PENamedTypeSymbol.MightContainExtensionMethods:
public override bool MightContainExtensionMethods
{
get
{
var uncommon = GetUncommonProperties();
if (uncommon == s_noUncommonProperties)
{
return false;
}
if (!uncommon.lazyContainsExtensionMethods.HasValue())
{
var contains = ThreeState.False;
// Dev11 supports extension methods defined on non-static
// classes, structs, delegates, and generic types.
switch (this.TypeKind)
{
case TypeKind.Class:
case TypeKind.Struct:
case TypeKind.Delegate:
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 1)
Addresses parts of #78827
Note: an implementation method for a non-static new extension method is an extension method, and therefore not imported as a static method (existing behavior, see
IsValidLookupCandidateInUsings) and cannot be invoked directly. It can only be called by extension invocation.Relates to test plan #76130