Files

36 lines
1.3 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 BoundConstantPattern : BoundPattern
{
public BoundExpression Value { get; }
public ConstantValue ConstantValue { get; }
public BoundConstantPattern(SyntaxNode syntax, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
: base(BoundKind.ConstantPattern, syntax, inputType, narrowedType, hasErrors || value.HasErrors())
{
Value = value;
ConstantValue = constantValue;
}
[DebuggerStepThrough]
public override BoundNode? Accept(BoundTreeVisitor visitor)
{
return visitor.VisitConstantPattern(this);
}
public BoundConstantPattern Update(BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType)
{
if (value != Value || constantValue != ConstantValue || !TypeSymbol.Equals(inputType, base.InputType, (TypeCompareKind)0) || !TypeSymbol.Equals(narrowedType, base.NarrowedType, (TypeCompareKind)0))
{
BoundConstantPattern boundConstantPattern = new BoundConstantPattern(Syntax, value, constantValue, inputType, narrowedType, base.HasErrors);
boundConstantPattern.CopyAttributes(this);
return boundConstantPattern;
}
return this;
}
}