Skip to content

Commit

Permalink
GH-153 - ConflictingArgumentAssignmentsAnalyzer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tpodolak committed Oct 2, 2022
1 parent 3880997 commit 154a51a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ private void AnalyzeInvocation(OperationAnalysisContext syntaxNodeContext)

var previousCallIndexers = FindCallInfoIndexers(substituteOperation);

var immutableHashSet = previousCallIndexers
var previousCallIndexerPositions = previousCallIndexers
.Select(indexerPropertyReferenceOperation => indexerPropertyReferenceOperation.GetIndexerPosition())
.ToImmutableHashSet();

foreach (var indexerExpressionSyntax in andDoesIndexers)
{
var position = indexerExpressionSyntax.GetIndexerPosition();
if (position.HasValue && immutableHashSet.Contains(position.Value))
if (position.HasValue && previousCallIndexerPositions.Contains(position.Value))
{
syntaxNodeContext.ReportDiagnostic(Diagnostic.Create(
DiagnosticDescriptorsProvider.ConflictingArgumentAssignments,
Expand All @@ -81,7 +81,7 @@ private IEnumerable<IOperation> FindCallInfoIndexers(IInvocationOperation invoca
foreach (var propertyReference in _callInfoFinder
.GetCallInfoContext(argumentOperation).IndexerAccessesOperations)
{
if (propertyReference.Parent is ISimpleAssignmentOperation)
if (propertyReference is IPropertyReferenceOperation && propertyReference.Parent is ISimpleAssignmentOperation)
{
yield return propertyReference;
}
Expand Down

0 comments on commit 154a51a

Please sign in to comment.