-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Ensure binder with BinderFlags.AttributeArgument is in the local binder chain
#81628
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
…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.
| /// <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)) |
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 didn't follow why !isExplicit is needed in this check.
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 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.
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.
My goal was to use most conservative conditions to fix failing tests.
|
@jcouv, @dotnet/roslyn-compiler For a second review. |
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.