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

Avoid AmbigMember in lookup of interfaces with nullability differences only #49338

Merged
merged 7 commits into from
Dec 18, 2020
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
17 changes: 13 additions & 4 deletions src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,11 +1058,20 @@ private static void LookupMembersInInterfacesWithoutInheritance(
if (interfaces.Length > 0)
{
var tmp = LookupResult.GetInstance();
foreach (TypeSymbol baseInterface in interfaces)
HashSet<NamedTypeSymbol> seenInterfaces = null;
Copy link
Contributor

@AlekseyTs AlekseyTs Dec 16, 2020

Choose a reason for hiding this comment

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

HashSet [](start = 16, length = 7)

Would it make sense to use pooled hash set? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason I didn't use the pool is that we'd need a new one for this specific comparer. Not sure that's warranted


In reply to: 544338611 [](ancestors = 544338611)

if (interfaces.Length > 1)
{
LookupMembersWithoutInheritance(tmp, baseInterface, name, arity, options, originalBinder, accessThroughType, diagnose, ref useSiteDiagnostics, basesBeingResolved);
MergeHidingLookupResults(current, tmp, basesBeingResolved, ref useSiteDiagnostics);
tmp.Clear();
seenInterfaces = new HashSet<NamedTypeSymbol>(Symbols.SymbolEqualityComparer.IgnoringNullable);
}

foreach (NamedTypeSymbol baseInterface in interfaces)
{
if (seenInterfaces is null || seenInterfaces.Add(baseInterface))
{
LookupMembersWithoutInheritance(tmp, baseInterface, name, arity, options, originalBinder, accessThroughType, diagnose, ref useSiteDiagnostics, basesBeingResolved);
MergeHidingLookupResults(current, tmp, basesBeingResolved, ref useSiteDiagnostics);
tmp.Clear();
}
}
tmp.Free();
}
Expand Down
Loading