Ensure binder with BinderFlags.AttributeArgument is in the local binder chain#81628
Merged
AlekseyTs merged 2 commits intodotnet:mainfrom Dec 11, 2025
Merged
Ensure binder with BinderFlags.AttributeArgument is in the local binder chain#81628AlekseyTs merged 2 commits intodotnet:mainfrom
BinderFlags.AttributeArgument is in the local binder chain#81628AlekseyTs merged 2 commits intodotnet:mainfrom
Conversation
…er chain The binder with the flag was injected manually as the current binder while binding attributes. Because of that BinderFlags.AttributeArgument was not preserved by `GetBinder` APIs. For example the API is used during binding of `nameof`. Various checks responsible for breaking infinite binding cycles were relying on the presence of the flag. Since after the change the flag is preserved when we are binding `nameof`, I had to add a fixup in several places to properly support IDS_FeatureInstanceMemberInNameof in context of an attribute. See dotnet#67461 that initially added support for the feature.
jjonescz
reviewed
Dec 10, 2025
| /// <returns>True if a reference to "this" is available.</returns> | ||
| internal bool HasThis(bool isExplicit, out bool inStaticContext) | ||
| { | ||
| if (!isExplicit && IsInsideNameof && Compilation.IsFeatureEnabled(MessageID.IDS_FeatureInstanceMemberInNameof)) |
Member
There was a problem hiding this comment.
I didn't follow why !isExplicit is needed in this check.
Contributor
Author
There was a problem hiding this comment.
I didn't follow why
!isExplicitis needed in this check.
There are no tests indicating that it must not be present. If you have a scenario in mind, please suggest an example.
Contributor
Author
There was a problem hiding this comment.
My goal was to use most conservative conditions to fix failing tests.
jjonescz
approved these changes
Dec 10, 2025
Contributor
Author
|
@jcouv, @dotnet/roslyn-compiler For a second review. |
333fred
approved these changes
Dec 11, 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.
Fixes #81576.
A binder with the flag was injected manually as the current binder while binding attributes. Because of that
BinderFlags.AttributeArgumentwas not preserved byGetBinderAPI. For example the API is used during binding ofnameof. Various checks responsible for breaking infinite binding cycles are relying on presence of the flag.Since after the change the flag is preserved when we are binding
nameof, I had to add a fixup in several places to properly supportIDS_FeatureInstanceMemberInNameoffeature in context of an attribute. See #67461 that initially added support for the feature.