-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Extensions: honor OverloadResolutionPriority attribute #78219
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 bool CanHaveOverloadResolutionPriority => !IsOverride && !IsExplicitInterfaceImplementation && (IsIndexer || IsIndexedProperty); | ||
| internal bool CanHaveOverloadResolutionPriority | ||
| => !IsOverride && !IsExplicitInterfaceImplementation && (IsIndexer || IsIndexedProperty || this.GetIsNewExtensionMember()); |
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.
| 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)) |
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.
| internal sealed override int TryGetOverloadResolutionPriority() | ||
| { | ||
| Debug.Assert(this.IsIndexer); | ||
| Debug.Assert(this.IsIndexer || this.GetIsNewExtensionMember()); |
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.
|
Done with review pass (commit 1) |
| { | ||
| var arg = new TypedConstant(DeclaringCompilation.GetSpecialType(SpecialType.System_Int32), TypedConstantKind.Primitive, priority); | ||
|
|
||
| AddSynthesizedAttribute(ref attributes, DeclaringCompilation.TrySynthesizeAttribute( |
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.
| if (UnderlyingMethod is SourcePropertyAccessorSymbol { AssociatedSymbol: SourcePropertySymbolBase extensionProperty }) | ||
| { | ||
| var priority = extensionProperty.OverloadResolutionPriority; | ||
| if (priority != 0) |
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.
| } | ||
|
|
||
| internal override int TryGetOverloadResolutionPriority() | ||
| => UnderlyingMethod.TryGetOverloadResolutionPriority(); |
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.
| } | ||
|
|
||
| internal override int TryGetOverloadResolutionPriority() | ||
| => UnderlyingMethod.TryGetOverloadResolutionPriority(); |
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.
| } | ||
|
|
||
| internal override int TryGetOverloadResolutionPriority() | ||
| => UnderlyingMethod.TryGetOverloadResolutionPriority(); |
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.
| var arg = new TypedConstant(DeclaringCompilation.GetSpecialType(SpecialType.System_Int32), TypedConstantKind.Primitive, priority); | ||
|
|
||
| AddSynthesizedAttribute(ref attributes, DeclaringCompilation.TrySynthesizeAttribute( | ||
| WellKnownMember.System_Runtime_CompilerServices_OverloadResolutionPriorityAttribute__ctor, |
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.
| System_Text_Encoding__get_UTF8, | ||
| System_Text_Encoding__GetString, | ||
|
|
||
| System_Runtime_CompilerServices_OverloadResolutionPriorityAttribute__ctor, |
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.
|
Done with review pass (commit 2) |
AlekseyTs
left a comment
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
|
@jjonescz for review. Thanks |
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