Files

39 lines
1.1 KiB
C#
Raw Permalink Normal View History

2026-08-27 10:56:38 -06:00
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
namespace Microsoft.CodeAnalysis.CSharp;
internal sealed class BoundSwitchLabel : BoundNode
{
public LabelSymbol Label { get; }
public BoundPattern Pattern { get; }
public BoundExpression? WhenClause { get; }
public BoundSwitchLabel(SyntaxNode syntax, LabelSymbol label, BoundPattern pattern, BoundExpression? whenClause, bool hasErrors = false)
: base(BoundKind.SwitchLabel, syntax, hasErrors || pattern.HasErrors() || whenClause.HasErrors())
{
Label = label;
Pattern = pattern;
WhenClause = whenClause;
}
[DebuggerStepThrough]
public override BoundNode? Accept(BoundTreeVisitor visitor)
{
return visitor.VisitSwitchLabel(this);
}
public BoundSwitchLabel Update(LabelSymbol label, BoundPattern pattern, BoundExpression? whenClause)
{
if (!SymbolEqualityComparer.ConsiderEverything.Equals(label, Label) || pattern != Pattern || whenClause != WhenClause)
{
BoundSwitchLabel boundSwitchLabel = new BoundSwitchLabel(Syntax, label, pattern, whenClause, base.HasErrors);
boundSwitchLabel.CopyAttributes(this);
return boundSwitchLabel;
}
return this;
}
}