Skip to content
Permalink
Browse files

Merge pull request #41683 from dotnet/merges/release/dev16.5-to-master

Merge release/dev16.5 to master
  • Loading branch information
msftbot committed Feb 14, 2020
2 parents 2b5fa1d + 82a17a5 commit e8a68c4ff457bcbef07afcccdf491b1966b8ac59
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/Compilers/CSharp/Portable/Symbols/SubstitutedMethodSymbol.cs
@@ -368,7 +368,8 @@ private int ComputeHashCode()
// (e.g, ignoring nullability) and want to retain the same hashcode. As such, consider only
// the original definition for the hashcode when we know equality is possible
var containingHashCode = _containingType.GetHashCode();
if (containingHashCode == this.OriginalDefinition.ContainingType.GetHashCode())
if (containingHashCode == this.OriginalDefinition.ContainingType.GetHashCode() &&
wasConstructedForAnnotations(this))
{
return code;
}
@@ -402,6 +403,24 @@ private int ComputeHashCode()
}

return code;

static bool wasConstructedForAnnotations(SubstitutedMethodSymbol method)
{
var typeArguments = method.TypeArgumentsWithAnnotations;
var typeParameters = method.OriginalDefinition.TypeParameters;

for (int i = 0; i < typeArguments.Length; i++)
{
if (!typeParameters[i].Equals(
typeArguments[i].Type,
TypeCompareKind.ConsiderEverything))
{
return false;
}
}

return true;
}
}

public sealed override bool Equals(Symbol obj, TypeCompareKind compareKind)

0 comments on commit e8a68c4

Please sign in to comment.
You can’t perform that action at this time.