38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System.Diagnostics;
|
|||
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
||
|
|
|
||
|
|
internal sealed class BoundConditionalAccess : BoundExpression
|
||
|
|
{
|
||
|
|
public new TypeSymbol Type => base.Type;
|
||
|
|
|
||
|
|
public BoundExpression Receiver { get; }
|
||
|
|
|
||
|
|
public BoundExpression AccessExpression { get; }
|
||
|
|
|
||
|
|
public BoundConditionalAccess(SyntaxNode syntax, BoundExpression receiver, BoundExpression accessExpression, TypeSymbol type, bool hasErrors = false)
|
||
|
|
: base(BoundKind.ConditionalAccess, syntax, type, hasErrors || receiver.HasErrors() || accessExpression.HasErrors())
|
||
|
|
{
|
||
|
|
Receiver = receiver;
|
||
|
|
AccessExpression = accessExpression;
|
||
|
|
}
|
||
|
|
|
||
|
|
[DebuggerStepThrough]
|
||
|
|
public override BoundNode? Accept(BoundTreeVisitor visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitConditionalAccess(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public BoundConditionalAccess Update(BoundExpression receiver, BoundExpression accessExpression, TypeSymbol type)
|
||
|
|
{
|
||
|
|
if (receiver != Receiver || accessExpression != AccessExpression || !TypeSymbol.Equals(type, Type, (TypeCompareKind)0))
|
||
|
|
{
|
||
|
|
BoundConditionalAccess boundConditionalAccess = new BoundConditionalAccess(Syntax, receiver, accessExpression, type, base.HasErrors);
|
||
|
|
boundConditionalAccess.CopyAttributes(this);
|
||
|
|
return boundConditionalAccess;
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
}
|