-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Ensure proper receiver value is used for a constrained call invocation #65642
Conversation
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.
Got through everything but the large test file, will take that up again tomorrow.
private enum ReceiverCaptureMode | ||
{ | ||
/// <summary> | ||
/// No special cupture of the receiver, unless arguments need to refere to it. |
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.
cupture -> capture
refere -> refer #Resolved
Default = 0, | ||
|
||
/// <summary> | ||
/// Used for a regular indexer coumpond assignment rewrite. |
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.
coumpond -> compound #Resolved
|
||
BoundLocal cache = _factory.Local(_factory.SynthesizedLocal(receiverType)); | ||
|
||
tempsOpt.Add(cache.LocalSymbol); |
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.
Consider not naming this Opt
, as it's required. #Resolved
&& !receiverRefLocal.Type.IsReferenceType | ||
&& !receiverRefLocal.Type.IsValueType |
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.
Could these be incorporated into the pattern? #Resolved
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.
Could these be incorporated into the pattern?
In theory we could, but I prefer to keep this check out of the pattern that is already big enough to comprehend and keep track of what is actually checked there.
|
||
var cache = _F.Local(_F.SynthesizedLocal(receiverType)); | ||
receiverBuilder.AddLocal(cache.LocalSymbol); | ||
receiverBuilder.AddStatement(_F.If(_F.Not(isValueTypeCheck), _F.Assignment(cache, receiver))); |
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.
Should we be asserting that this assignment is in line with IsComplexConditionalInitializationOfReceiverRef
, like we do in LocalRewriter_Call
? #Resolved
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.
Should we be asserting that this assignment is in line with
IsComplexConditionalInitializationOfReceiverRef
, like we do inLocalRewriter_Call
?
It is not in line with that and the assert would fail. An assignment that we create here doesn't have a special shape and we don't need to treat it specially anywhere.
@@ -308,6 +308,11 @@ internal override bool IsPinned | |||
} | |||
} | |||
|
|||
internal override bool IsKnownToReferToTempIfReferenceType |
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.
Should we seal this? #Resolved
@@ -79,6 +79,11 @@ protected LocalSymbol() | |||
get; | |||
} | |||
|
|||
internal abstract bool IsKnownToReferToTempIfReferenceType |
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.
Consider adding a comment this this to explain what it's used for. #Resolved
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.
Why not name it just RefersToTempIfReferenceType
?
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.
Why not name it just
RefersToTempIfReferenceType
?
I think the fact that RefersToTempIfReferenceType
is false might be misinterpreted as the local doesn't refer to a temp if reference type. However, this isn't what I am trying to convey.
typo in this and a few following method names In reply to: 1330335753 Refers to: src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenCallTests.cs:17544 in 36930c5. [](commit_id = 36930c5, deletion_comment = False) |
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
Show resolved
Hide resolved
It is probably not necessary to do a thorough review of every IL change in that file. If you need some help with specific IL changes, we can walk though the diff together offline. |
@dotnet/roslyn-compiler For the second review |
3 similar comments
@dotnet/roslyn-compiler For the second review |
@dotnet/roslyn-compiler For the second review |
@dotnet/roslyn-compiler For the second review |
@dotnet/roslyn-compiler For the second review, this PR is already one week old and I have another change in the pipeline, that builds on top of changes in this PR. |
Related to #63221.