-
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
Skip checks for overridden or hidden members in overload resolution with extension methods #68316
Conversation
…ith extension methods
in CallingConventionInfo callingConventionInfo = default) | ||
where TMember : Symbol | ||
{ | ||
var results = result.ResultsBuilder; | ||
|
||
// No need to check for overridden or hidden methods | ||
// if the members were resolved as extension methods. | ||
bool checkOverriddenOrHidden = !isExtensionMethodResolution; |
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.
Should we confirm that all containing types are static types derived from System.Object
?
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 4), assuming CI is passing
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
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 7)
@dotnet/roslyn-compiler for a second review, thanks. |
src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionPerfTests.cs
Show resolved
Hide resolved
var refA = CompileIL(sourceA, prependDefaultHeader: false); | ||
|
||
// The calls to B.F3(o) and o.F3() should bind to B.F3 and should not be | ||
// considered ambiguous with A.F3 because B is derived from A. |
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.
Does the language specify this?
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.
I'm not sure if the language specifies this, but this is the existing behavior, so I wanted to avoid an unnecessary breaking change.
// No need to check for overridden or hidden methods if the members were | ||
// resolved as extension methods and the extension methods are defined in | ||
// types derived from System.Object. | ||
bool checkOverriddenOrHidden = !(isExtensionMethodResolution && |
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.
nit: it feels like this might be easier to understand as !isExtensionMethodResolution || !members.All(...)
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.
To me, both forms seem equally difficult to read. I'll leave it as is since the current form matches the comment above which seems relatively clear.
in CallingConventionInfo callingConventionInfo = default) | ||
where TMember : Symbol | ||
{ | ||
var results = result.ResultsBuilder; | ||
|
||
// No need to check for overridden or hidden methods if the members were | ||
// resolved as extension methods and the extension methods are defined in | ||
// types derived from System.Object. |
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.
Is this optimization only applicable for extension method overload resolution? What about normal static method overload resolution?
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.
I limited the optimization to extension methods because it was easy to catch that case in the caller. I think it's less likely there is an issue with static method overloads since the containing types in that case would need to be in the same class or base classes, so few containing types and, as a result, few entries in the dictionary returned from PartitionMembersByContainingType()
.
…ith extension methods (dotnet#68316)
Improves Intellisense performance by ~35% for scenario in #67926.