-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Check reference equality for strongly-typed equals in records #51149
Changes from 5 commits
abbda7e
177fa99
bc934c5
64d341f
da031eb
731ab65
a5836bd
5970cc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -155,7 +155,7 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState, | |||
} | ||||
|
||||
fields.Free(); | ||||
|
||||
retExpr = F.LogicalOr(F.ObjectEqual(F.This(), other), retExpr); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we should do similar change for the other consumer of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlekseyTs That sounds reasonable. Should I start doing this and update tests? or do you want to wait for another team member to confirm? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think we need to wait for the confirmation from other team members. If I was working on this change, I would just do this (the improvement of code gen for Anonymous Types). In reply to: 575327671 [](ancestors = 575327671) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlekseyTs I made the change for anonymous types for C# and updated the tests.
Found it: Line 56 in afd1030
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
See In reply to: 575376850 [](ancestors = 575376850) |
||||
F.CloseMethod(F.Block(F.Return(retExpr))); | ||||
} | ||||
catch (SyntheticBoundNodeFactory.MissingPredefinedMember ex) | ||||
|
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.
Is this check duplicated in the equality operator now? Should it be removed from there? #Closed
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.
@AlekseyTs The issue is that users can re-define
Equals
.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.
And? The redefined Equals should still do the right thing.
In reply to: 574776221 [](ancestors = 574776221)
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.
@AlekseyTs Just tried to remove the check from
==
implementation, and now null comparison fails unfortunately 😕The current implementation looks like:
This was caught by the following test:
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 guess we could change the code gen to the following:
However, I am not sure if this is going to give us any noticeable improvement.
In reply to: 575128469 [](ancestors = 575128469)
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.
@dotnet/roslyn-compiler Thoughts?
In reply to: 575311021 [](ancestors = 575311021,575128469)
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.
In the email thread, I believe we agreed to duplicate the equality check.