40 lines
1.7 KiB
C#
40 lines
1.7 KiB
C#
using System.Collections.Immutable;
|
|
using System.Diagnostics;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal sealed class BoundITuplePattern : BoundPattern
|
|
{
|
|
public MethodSymbol GetLengthMethod { get; }
|
|
|
|
public MethodSymbol GetItemMethod { get; }
|
|
|
|
public ImmutableArray<BoundPositionalSubpattern> Subpatterns { get; }
|
|
|
|
public BoundITuplePattern(SyntaxNode syntax, MethodSymbol getLengthMethod, MethodSymbol getItemMethod, ImmutableArray<BoundPositionalSubpattern> subpatterns, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
|
|
: base(BoundKind.ITuplePattern, syntax, inputType, narrowedType, hasErrors || subpatterns.HasErrors())
|
|
{
|
|
GetLengthMethod = getLengthMethod;
|
|
GetItemMethod = getItemMethod;
|
|
Subpatterns = subpatterns;
|
|
}
|
|
|
|
[DebuggerStepThrough]
|
|
public override BoundNode? Accept(BoundTreeVisitor visitor)
|
|
{
|
|
return visitor.VisitITuplePattern(this);
|
|
}
|
|
|
|
public BoundITuplePattern Update(MethodSymbol getLengthMethod, MethodSymbol getItemMethod, ImmutableArray<BoundPositionalSubpattern> subpatterns, TypeSymbol inputType, TypeSymbol narrowedType)
|
|
{
|
|
if (!SymbolEqualityComparer.ConsiderEverything.Equals(getLengthMethod, GetLengthMethod) || !SymbolEqualityComparer.ConsiderEverything.Equals(getItemMethod, GetItemMethod) || subpatterns != Subpatterns || !TypeSymbol.Equals(inputType, base.InputType, (TypeCompareKind)0) || !TypeSymbol.Equals(narrowedType, base.NarrowedType, (TypeCompareKind)0))
|
|
{
|
|
BoundITuplePattern boundITuplePattern = new BoundITuplePattern(Syntax, getLengthMethod, getItemMethod, subpatterns, inputType, narrowedType, base.HasErrors);
|
|
boundITuplePattern.CopyAttributes(this);
|
|
return boundITuplePattern;
|
|
}
|
|
return this;
|
|
}
|
|
}
|