Skip to content
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

Merged
merged 3 commits into from
Dec 6, 2022

Conversation

AlekseyTs
Copy link
Contributor

Related to #63221.

@AlekseyTs AlekseyTs requested a review from a team as a code owner November 28, 2022 19:13
Copy link
Member

@333fred 333fred left a 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.
Copy link
Member

@333fred 333fred Nov 28, 2022

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.
Copy link
Member

@333fred 333fred Nov 28, 2022

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);
Copy link
Member

@333fred 333fred Nov 28, 2022

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

Comment on lines +508 to +509
&& !receiverRefLocal.Type.IsReferenceType
&& !receiverRefLocal.Type.IsValueType
Copy link
Member

@333fred 333fred Nov 28, 2022

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

Copy link
Contributor Author

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)));
Copy link
Member

@333fred 333fred Nov 28, 2022

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

Copy link
Contributor Author

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?

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
Copy link
Member

@333fred 333fred Nov 28, 2022

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
Copy link
Member

@333fred 333fred Nov 28, 2022

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

Copy link
Member

@jjonescz jjonescz Nov 29, 2022

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?

Copy link
Contributor Author

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.

@jjonescz
Copy link
Member

jjonescz commented Nov 29, 2022

    public void GenericTypeParameterAsReceiver_ImpicitIndexIndexer_Class()

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)

@AlekseyTs
Copy link
Contributor Author

Got through everything but the large test file, will take that up again tomorrow.

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.

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review

3 similar comments
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review

@AlekseyTs
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants