Skip to content

Commit

Permalink
Analyze properties with conditional attributes in patterns (#51001)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv authored Feb 10, 2021
1 parent 09c1881 commit d8a22e5
Show file tree
Hide file tree
Showing 4 changed files with 1,719 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal abstract partial class AbstractFlowPass<TLocalState, TLocalFunctionStat
public override BoundNode VisitSwitchStatement(BoundSwitchStatement node)
{
// dispatch to the switch sections
var (initialState, afterSwitchState) = VisitSwitchStatementDispatch(node);
var afterSwitchState = VisitSwitchStatementDispatch(node);

// visit switch sections
var switchSections = node.SwitchSections;
Expand All @@ -36,7 +36,7 @@ public override BoundNode VisitSwitchStatement(BoundSwitchStatement node)
return null;
}

protected virtual (TLocalState initialState, TLocalState afterSwitchState) VisitSwitchStatementDispatch(BoundSwitchStatement node)
protected virtual TLocalState VisitSwitchStatementDispatch(BoundSwitchStatement node)
{
// visit switch header
VisitRvalue(node.Expression);
Expand Down Expand Up @@ -77,7 +77,7 @@ protected virtual (TLocalState initialState, TLocalState afterSwitchState) Visit
Join(ref afterSwitchState, ref initialState);
}

return (initialState, afterSwitchState);
return afterSwitchState;
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5117,6 +5117,12 @@ private void ApplyMemberPostConditions(BoundExpression? receiverOpt, MethodSymbo
return;
}

ApplyMemberPostConditions(receiverSlot, method);
}

private void ApplyMemberPostConditions(int receiverSlot, MethodSymbol method)
{
Debug.Assert(receiverSlot >= 0);
do
{
var type = method.ContainingType;
Expand Down
Loading

0 comments on commit d8a22e5

Please sign in to comment.