-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Support consumption of instance increment operators #77098
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
Support consumption of instance increment operators #77098
Conversation
|
@cston, @dotnet/roslyn-compiler For the second review |
| } | ||
| else if ((options & LookupOptions.MustBeOperator) != 0 && unwrappedSymbol is not MethodSymbol { MethodKind: MethodKind.UserDefinedOperator }) | ||
| { | ||
| return LookupResult.Empty(); |
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.
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.
Are we testing this code path?
Not yet
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.
Are we testing this code path?
Added Increment_093_Consumption_OrdinaryMethod
| bool resultIsUsed = ResultIsUsed(node); | ||
|
|
||
| if ((kind is (UnaryOperatorKind.PostfixIncrement or UnaryOperatorKind.PostfixDecrement) && resultIsUsed) || | ||
| !CheckValueKind(node, operand, BindValueKind.RefersToLocation | BindValueKind.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded)) |
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.
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.
Are we testing
BindValueKind.Assignable?
Not specifically. A an increment/decrement target must be assignable and this is checked on line 2272. Therefore, I do not find it critical to cover that specific dimension in error scenarios.
| OverloadResolution.Options.None); | ||
|
|
||
| typeArguments.Free(); | ||
| diagnostics.Add(node, useSiteInfo); |
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.
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.
Are we testing use-site diagnostics?
No
| public void Increment_077_Consumption_Postfix_Used([CombinatorialValues("++", "--")] string op, bool fromMetadata) | ||
| { | ||
| var source1 = @" | ||
| public class C1 |
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.
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.
Are we testing with struct, or with type parameter with/without class or struct constraints?
I do not find these scenarios interesting. The test is not about code that we generate, it is about an error that doesn't depend on the mentioned aspects.
| public void Increment_078_Consumption_Postfix_Used([CombinatorialValues("++", "--")] string op, bool fromMetadata) | ||
| { | ||
| var source1 = @" | ||
| public class C1 |
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.
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.
Are we testing with struct, or with type parameter with/without class or struct constraints?
I do not find these scenarios interesting. The test is verifying fall back to the legacy operators.
c3beaf8
into
dotnet:features/UserDefinedCompoundAssignment
No description provided.