Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public CSharpOperationFactory(SemanticModel semanticModel)
return CreateBoundAwaitExpressionOperation((BoundAwaitExpression)boundNode);
case BoundKind.ArrayAccess:
return CreateBoundArrayAccessOperation((BoundArrayAccess)boundNode);
case BoundKind.ImplicitIndexerAccess:
return CreateBoundImplicitIndexerAccessOperation((BoundImplicitIndexerAccess)boundNode);
case BoundKind.NameOfOperator:
return CreateBoundNameOfOperatorOperation((BoundNameOfOperator)boundNode);
case BoundKind.ThrowExpression:
Expand Down Expand Up @@ -304,7 +306,6 @@ public CSharpOperationFactory(SemanticModel semanticModel)
case BoundKind.StackAllocArrayCreation:
case BoundKind.TypeExpression:
case BoundKind.TypeOrValueExpression:
case BoundKind.ImplicitIndexerAccess:

ConstantValue? constantValue = (boundNode as BoundExpression)?.ConstantValue;
bool isImplicit = boundNode.WasCompilerGenerated;
Expand Down Expand Up @@ -1486,6 +1487,28 @@ private IArrayElementReferenceOperation CreateBoundArrayAccessOperation(BoundArr
return new ArrayElementReferenceOperation(arrayReference, indices, _semanticModel, syntax, type, isImplicit);
}

private IOperation CreateBoundImplicitIndexerAccessOperation(BoundImplicitIndexerAccess boundIndexerAccess)
{
IOperation instance = Create(boundIndexerAccess.Receiver);
IOperation argument = Create(boundIndexerAccess.Argument);
SyntaxNode syntax = boundIndexerAccess.Syntax;
ITypeSymbol? type = boundIndexerAccess.GetPublicTypeSymbol();
bool isImplicit = boundIndexerAccess.WasCompilerGenerated;

if (boundIndexerAccess.LengthOrCountAccess.Kind == BoundKind.ArrayLength)
{
return new ArrayElementReferenceOperation(instance, ImmutableArray.Create(argument), _semanticModel, syntax, type, isImplicit);
}

var lengthSymbol = Binder.GetPropertySymbol(boundIndexerAccess.LengthOrCountAccess, out _, out _).GetPublicSymbol();
var indexerSymbol = Binder.GetIndexerOrImplicitIndexerSymbol(boundIndexerAccess).GetPublicSymbol();

Debug.Assert(lengthSymbol is not null);
Debug.Assert(indexerSymbol is not null);

return new ImplicitIndexerReferenceOperation(instance, argument, lengthSymbol, indexerSymbol, _semanticModel, syntax, type, isImplicit);
}

private INameOfOperation CreateBoundNameOfOperatorOperation(BoundNameOfOperator boundNameOfOperator)
{
IOperation argument = Create(boundNameOfOperator.Argument);
Expand Down
Loading