Skip to content

Commit

Permalink
Merge pull request #36776 from dotnet/merges/master-to-master-vs-deps
Browse files Browse the repository at this point in the history
Merge master to master-vs-deps
  • Loading branch information
dotnet-automerge-bot authored Jun 26, 2019
2 parents b156732 + c5f4c27 commit c209b0a
Show file tree
Hide file tree
Showing 9 changed files with 562 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static Symbol FindExplicitlyImplementedMember(
// interface in its base class list that contains a member ..."
MultiDictionary<NamedTypeSymbol, NamedTypeSymbol>.ValueSet set = containingType.InterfacesAndTheirBaseInterfacesNoUseSiteDiagnostics[explicitInterfaceNamedType];
int setCount = set.Count;
if (setCount == 0 || !set.Contains(explicitInterfaceNamedType))
if (setCount == 0 || !set.Contains(explicitInterfaceNamedType, TypeSymbol.EqualsObliviousNullableModifierMatchesAny))
{
//we'd like to highlight just the type part of the name
var explicitInterfaceSyntax = explicitInterfaceSpecifierSyntax.Name;
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ private InterfaceInfo GetInterfaceInfo()

internal static readonly EqualityComparer<TypeSymbol> EqualsIgnoringNullableComparer = new TypeSymbolComparer(TypeCompareKind.IgnoreNullableModifiersForReferenceTypes);

internal static readonly EqualityComparer<TypeSymbol> EqualsObliviousNullableModifierMatchesAny = new TypeSymbolComparer(TypeCompareKind.ObliviousNullableModifierMatchesAny);

internal static readonly EqualityComparer<TypeSymbol> EqualsAllIgnoreOptionsPlusNullableWithUnknownMatchesAnyComparer =
new TypeSymbolComparer(TypeCompareKind.AllIgnoreOptions & ~(TypeCompareKind.IgnoreNullableModifiersForReferenceTypes));

Expand Down
32 changes: 32 additions & 0 deletions src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,16 @@ internal static bool IsPrimitiveRecursiveStruct(this TypeSymbol t)
/// </summary>
internal static int ComputeHashCode(this NamedTypeSymbol type)
{
Debug.Assert(!type.Equals(type.OriginalDefinition, TypeCompareKind.AllIgnoreOptions) || wasConstructedForAnnotations(type));

if (wasConstructedForAnnotations(type))
{
// A type that uses its own type parameters as type arguments was constructed only for the purpose of adding annotations.
// In that case we'll use the hash from the definition.

return type.OriginalDefinition.GetHashCode();
}

int code = type.OriginalDefinition.GetHashCode();
code = Hash.Combine(type.ContainingType, code);

Expand Down Expand Up @@ -1209,6 +1219,28 @@ internal static int ComputeHashCode(this NamedTypeSymbol type)
code++;
}
return code;

static bool wasConstructedForAnnotations(NamedTypeSymbol type)
{
do
{
var typeArguments = type.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics;
var typeParameters = type.OriginalDefinition.TypeParameters;

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

type = type.ContainingType;
}
while (type is object && !type.IsDefinition);

return true;
}
}

/// <summary>
Expand Down
Loading

0 comments on commit c209b0a

Please sign in to comment.