Skip to content

Conversation

RikkiGibson
Copy link
Member

@RikkiGibson RikkiGibson commented Jul 16, 2025

#78828

Also handles some extension property patterns cases.

Relates to test plan #76130

if (expr == null || _disableNullabilityAnalysis) return;
if (expr == null
// BoundExpressionWithNullability is not produced by the binder but is used within nullability analysis to pass information to internal components.
|| expr.Kind == BoundKind.ExpressionWithNullability
Copy link
Member Author

@RikkiGibson RikkiGibson Jul 16, 2025

Choose a reason for hiding this comment

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

At first I tried to just add this kind to s_skippedExpressions. But that just controls whether the debug visitor will visit that kind. Essentially it just states an expectation that NullableWalker won't visit something, when, what we want here is the opposite, to tolerate that NullableWalker will visit something which the debug verifier won't visit. Possibly I misunderstood something, though, and this isn't the best place to make this change, or an appropriate type to use.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is basically being done so that we can cook up a receiver expression for the property pattern access, and let the VisitArguments machinery handle the reinference of the extension, conversion of property receiver to extension parameter type, etc.

Copy link
Member

Choose a reason for hiding this comment

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

I guess my question is: should we actually be peaking through the BoundExpressionWithNullability here and setting the underlying expression's state? Feels like we may miss something if we don't?

Copy link
Member Author

@RikkiGibson RikkiGibson Jul 17, 2025

Choose a reason for hiding this comment

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

The issue is there is no underlying expression in the bound tree for an extension property pattern. I just know what the receiver type is and would like to thread it through, having all the extension reinference and conversion checks from VisitArguments just work.

@RikkiGibson RikkiGibson marked this pull request as ready for review July 16, 2025 22:44
@RikkiGibson RikkiGibson requested a review from a team as a code owner July 16, 2025 22:44
if (expr == null || _disableNullabilityAnalysis) return;
if (expr == null
// BoundExpressionWithNullability is not produced by the binder but is used within nullability analysis to pass information to internal components.
|| expr.Kind == BoundKind.ExpressionWithNullability
Copy link
Member

Choose a reason for hiding this comment

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

I guess my question is: should we actually be peaking through the BoundExpressionWithNullability here and setting the underlying expression's state? Feels like we may miss something if we don't?

item = null;
}
var list = M2(item); // List<string?>
Copy link
Member

@333fred 333fred Jul 16, 2025

Choose a reason for hiding this comment

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

Consider verifying this assertion. #Resolved

item = null;
}
var list = M2(item); // List<string?>
Copy link
Member

@333fred 333fred Jul 16, 2025

Choose a reason for hiding this comment

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

Consider verifying this assertion. #Resolved

item = null;
}
var list = M2(item); // List<string?>
Copy link
Member

@333fred 333fred Jul 16, 2025

Choose a reason for hiding this comment

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

Consider verifying this assertion. #Resolved

@jcouv jcouv added the Feature - Extension Everything The extension everything feature label Jul 17, 2025
@jcouv jcouv self-assigned this Jul 17, 2025
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (commit 3)

@RikkiGibson RikkiGibson requested review from 333fred and jcouv July 24, 2025 00:03
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (commit 6)

@RikkiGibson RikkiGibson merged commit 6310b37 into dotnet:main Jul 25, 2025
24 checks passed
@RikkiGibson RikkiGibson deleted the ext-nullability-3 branch July 25, 2025 01:39
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 25, 2025
333fred added a commit to 333fred/roslyn that referenced this pull request Jul 25, 2025
…rlier

* upstream/main: (217 commits)
  Fix tests
  Fix tests
  Fix tests
  Fix tests
  Fix tests
  Fix tests
  Reduce allocations during CommonCompletionItem.Create (dotnet#79591)
  Fix tests
  Fix tests
  Fix tests
  Fix tests
  Add test
  Fix tests
  Add work item
  Fix eol handling on the last token in a file when formatting code actions
  remove unchecked values from tests
  [main] Source code updates from dotnet/dotnet (dotnet#79599)
  Nullable extensions: Add assertion to AsMemberOfType and handle failures (dotnet#79428)
  Avoid adding dependency on System.Threading.Channels to InteractiveHost (dotnet#79594)
  Update debugger contracts to 18.0.0-beta.25353.1 (dotnet#79277)
  ...
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Extension Everything The extension everything feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants