Skip to content

Add handling for RefKindExtensions.StrictIn in CodeGenerator.HasHome - #85706

Merged
AlekseyTs merged 3 commits into
dotnet:mainfrom
AlekseyTs:Issue84486
Sep 22, 2026
Merged

AlekseyTs merged 3 commits into
dotnet:mainfrom
AlekseyTs:Issue84486

Conversation

@AlekseyTs

@AlekseyTs AlekseyTs commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #84486

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 19, 2026 01:54
@AlekseyTs
AlekseyTs requested a review from a team as a code owner September 19, 2026 01:54
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Moderate code-generation findings remain unresolved, along with missing regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

This pull request updates C# lowering and code generation to handle RefKindExtensions.StrictIn when determining addressable homes.

Changes:

  • Handles StrictIn locals and BoundDup nodes.
  • Propagates address-kind requirements through conditional receivers.
  • Adjusts readonly address and receiver checks.
File Summary Final findings
src/​Compilers/​CSharp/​Portable/​Lowering/​LocalRewriter/​LocalRewriter_Call.cs Updates receiver home checks. No final comments.
src/​Compilers/​CSharp/​Portable/​Lowering/​LocalRewriter/​LocalRewriter_AssignmentOperator.cs Adjusts extension property receiver handling. No final comments.
src/​Compilers/​CSharp/​Portable/​CodeGen/​EmitExpression.cs Localizes argument address-kind mapping. No final comments.
src/​Compilers/​CSharp/​Portable/​CodeGen/​EmitAddress.cs Propagates address kinds. No final comments.
src/​Compilers/​CSharp/​Portable/​CodeGen/​CodeGenerator_HasHome.cs Implements StrictIn home logic and documentation. moderate (3 votes): Add regression coverage for explicit in values, including readonly/non-readonly and complex receiver paths.
moderate (2 votes): Remove or replace the tautological StrictIn assertion at lines 125 and 154.
nit (3 votes): Fix documentation spelling errors.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 19, 2026 03:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Contradictory StrictIn assertions remain, and focused regression coverage is missing.

Review effort: Lite
Findings: None

Resolved since last review (3)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Remove contradictory StrictIn assertion in BoundDup handling

src/​Compilers/​CSharp/​Portable/​CodeGen/​CodeGenerator_HasHome.cs:158

This branch is entered only after dupRefKind == RefKindExtensions.StrictIn, so the assertion is guaranteed to fail in DEBUG whenever the new BoundDup handling is exercised. The optimizer preserves a local's ref kind when creating BoundDup; remove the contradictory assertion and keep returning true for readonly address kinds.

}
else if (localRefKind == RefKindExtensions.StrictIn)
{
Debug.Assert(localRefKind != RefKindExtensions.StrictIn, "Add a test if this assert fails for a the scenario.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be probably simplified to just false? Also there seems to be a typo ("a the"). Applies also to the same assert below.

Suggested change
Debug.Assert(localRefKind != RefKindExtensions.StrictIn, "Add a test if this assert fails for a the scenario.");
Debug.Assert(false, "Add a test if this assert fails for a scenario.");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form of condition is intentional, I think assert prints it when it fails. I will fix the typo. Thanks.

Copilot AI review requested due to automatic review settings September 21, 2026 16:01
@AlekseyTs
AlekseyTs requested review from a team and jjonescz September 21, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate findings include assertion failures on supported StrictIn paths and a missing regression test.

Review effort: Lite
Findings: None

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeGenerator.HasHome most likely lacking proper handling for RefKindExtensions.StrictIn

3 participants