Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ModifierComparer use type references instead of definition #7557

Merged
merged 1 commit into from
Jun 24, 2021
Merged
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 @@ -129,8 +129,8 @@ private string GetReturnValueModifier(IMethodDefinition method)

private class ModifierComparer : IEqualityComparer<ICustomModifier>
{
private readonly static IEqualityComparer<ITypeDefinition> TypeComparer =
CciComparers.Default.GetEqualityComparer<ITypeDefinition>();
private readonly static IEqualityComparer<ITypeReference> TypeComparer =
CciComparers.Default.GetEqualityComparer<ITypeReference>();

private ModifierComparer() { }

Expand All @@ -144,7 +144,7 @@ public bool Equals(ICustomModifier x, ICustomModifier y)
}

return x.IsOptional == y.IsOptional &&
TypeComparer.Equals(x.Modifier.ResolvedType, y.Modifier.ResolvedType);
TypeComparer.Equals(x.Modifier, y.Modifier);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this allow both ICustomModifiers to be unresolved but disallow one or the other (and not both) to be resolved❔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just using the type-reference to do the comparison so it's irrelevant if either type is/can be resolved. This is consistent with how we already compare parameter types.

}

public int GetHashCode(ICustomModifier obj)
Expand All @@ -154,7 +154,7 @@ public int GetHashCode(ICustomModifier obj)
return 0;
}

return (obj.IsOptional ? 1 : 0) | TypeComparer.GetHashCode(obj.Modifier.ResolvedType) << 1;
return (obj.IsOptional ? 1 : 0) | TypeComparer.GetHashCode(obj.Modifier) << 1;
}
}
}
Expand Down