Extensions: honor OverloadResolutionPriority attribute#78219
Merged
jcouv merged 6 commits intodotnet:mainfrom Apr 28, 2025
Merged
Extensions: honor OverloadResolutionPriority attribute#78219jcouv merged 6 commits intodotnet:mainfrom
jcouv merged 6 commits intodotnet:mainfrom
Conversation
AlekseyTs
reviewed
Apr 22, 2025
|
|
||
| internal bool CanHaveOverloadResolutionPriority => !IsOverride && !IsExplicitInterfaceImplementation && (IsIndexer || IsIndexedProperty); | ||
| internal bool CanHaveOverloadResolutionPriority | ||
| => !IsOverride && !IsExplicitInterfaceImplementation && (IsIndexer || IsIndexedProperty || this.GetIsNewExtensionMember()); |
Contributor
AlekseyTs
reviewed
Apr 22, 2025
| return (null, null); | ||
| } | ||
| else if (IsIndexer && CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.OverloadResolutionPriorityAttribute)) | ||
| else if ((IsIndexer || this.GetIsNewExtensionMember()) && CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.OverloadResolutionPriorityAttribute)) |
Contributor
AlekseyTs
reviewed
Apr 22, 2025
| internal sealed override int TryGetOverloadResolutionPriority() | ||
| { | ||
| Debug.Assert(this.IsIndexer); | ||
| Debug.Assert(this.IsIndexer || this.GetIsNewExtensionMember()); |
Contributor
Contributor
|
Done with review pass (commit 1) |
AlekseyTs
reviewed
Apr 24, 2025
| { | ||
| var arg = new TypedConstant(DeclaringCompilation.GetSpecialType(SpecialType.System_Int32), TypedConstantKind.Primitive, priority); | ||
|
|
||
| AddSynthesizedAttribute(ref attributes, DeclaringCompilation.TrySynthesizeAttribute( |
Contributor
AlekseyTs
reviewed
Apr 24, 2025
| if (UnderlyingMethod is SourcePropertyAccessorSymbol { AssociatedSymbol: SourcePropertySymbolBase extensionProperty }) | ||
| { | ||
| var priority = extensionProperty.OverloadResolutionPriority; | ||
| if (priority != 0) |
Contributor
AlekseyTs
reviewed
Apr 24, 2025
| } | ||
|
|
||
| internal override int TryGetOverloadResolutionPriority() | ||
| => UnderlyingMethod.TryGetOverloadResolutionPriority(); |
Contributor
AlekseyTs
reviewed
Apr 24, 2025
| } | ||
|
|
||
| internal override int TryGetOverloadResolutionPriority() | ||
| => UnderlyingMethod.TryGetOverloadResolutionPriority(); |
Contributor
AlekseyTs
reviewed
Apr 24, 2025
| } | ||
|
|
||
| internal override int TryGetOverloadResolutionPriority() | ||
| => UnderlyingMethod.TryGetOverloadResolutionPriority(); |
Contributor
AlekseyTs
reviewed
Apr 24, 2025
| var arg = new TypedConstant(DeclaringCompilation.GetSpecialType(SpecialType.System_Int32), TypedConstantKind.Primitive, priority); | ||
|
|
||
| AddSynthesizedAttribute(ref attributes, DeclaringCompilation.TrySynthesizeAttribute( | ||
| WellKnownMember.System_Runtime_CompilerServices_OverloadResolutionPriorityAttribute__ctor, |
Contributor
AlekseyTs
reviewed
Apr 24, 2025
| System_Text_Encoding__get_UTF8, | ||
| System_Text_Encoding__GetString, | ||
|
|
||
| System_Runtime_CompilerServices_OverloadResolutionPriorityAttribute__ctor, |
Contributor
Contributor
|
Done with review pass (commit 2) |
AlekseyTs
approved these changes
Apr 25, 2025
Contributor
AlekseyTs
left a comment
There was a problem hiding this comment.
LGTM (commit 4), assuming CI is passing
Member
Author
|
@jjonescz for review. Thanks |
jjonescz
approved these changes
Apr 28, 2025
This was referenced Apr 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following LDM 2025-04-16
The "containing type" for purpose of ORPA is the enclosing static class.
We synthesize an ORPA on the implementation method for accessors to have same prioritization between usage as extension and usage via static/implementation method.
Relates to test plan #76130